Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types to Tip #26173

Merged
merged 3 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/components/src/tip/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
/**
* Internal dependencies
* WordPress dependencies
*/
import { SVG, Path } from '../';
import { SVG, Path } from '@wordpress/primitives';
Comment on lines -2 to +4
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to make it possible to add types to Tip. Is there a reason why we weren't importing this directly from primitives?


/**
* @typedef Props
* @property {import('@wordpress/element').WPNode} children Children to render in the tip.
*/

/**
* @param {Props} props
* @return {JSX.Element} Element
*/
function Tip( props ) {
return (
<div className="components-tip">
Expand Down
3 changes: 2 additions & 1 deletion packages/components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"references": [],
"include": [
"src/dashicon/*"
"src/dashicon/*",
"src/tip/*"
],
}
6 changes: 6 additions & 0 deletions packages/element/src/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ import { isString } from 'lodash';
* @typedef {import('react').ComponentType} WPComponent
*/

/**
* Object containing a React node.
*
* @typedef {import('react').ReactNode} WPNode
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd vote for dropping the aliases and using the react types directly. There's no good way to re-export TS types via JavaScript and this isn't going to be sustainable.

/**
* Object containing a React synthetic event.
*
Expand Down