-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add types to Tip #26173
Conversation
* Internal dependencies | ||
* WordPress dependencies | ||
*/ | ||
import { SVG, Path } from '../'; | ||
import { SVG, Path } from '@wordpress/primitives'; |
There was a problem hiding this comment.
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?
"src/dashicon/*", | ||
"src/tip/*" | ||
], | ||
"references": [ { "path": "../primitives" } ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to add references so TypeScript can figure out the build order properly. It’s the one “gotcha” to the setup
We would want this for all the monorepo packages this package depends on, but we have a problem where this isn't a "leaf" package so we need to add them as we need them.
This should fix the test issues that appeared on this branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add one for @wordpress/element
as well. We could add all the packages that have opted-in to typing and appear in this package`s package.json.
packages/element/src/react.js
Outdated
/** | ||
* Object containing a React node. | ||
* | ||
* @typedef {import('react').ReactNode} WPNode | ||
*/ | ||
|
There was a problem hiding this comment.
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.
Description
ReactNode
type to be able to properly typechildren
Tip
componentHow has this been tested?
Local typecheck.
Types of changes
New types.
Checklist:
/cc @sirreal