-
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
Components: enhancements to TypeScript migration guidelines #41669
Components: enhancements to TypeScript migration guidelines #41669
Conversation
} | ||
``` | ||
|
||
3. Add the folders to the `tsconfig.json` file. |
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.
Points 3, 4 and 5 here are unchanged apart from their index, that shiftet by 1 after adding a new point (now no. 2)
// Before: | ||
function MyComponent( { myProp1, myProp2, ...restProps } ) { /* ... */ } | ||
|
||
// After: | ||
function MyComponent( props ) { | ||
const { myProp1, myProp2, ...restProps } = props; |
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.
Good clarification with the example 👍
import type { ComponentOwnProps } from './types'; | ||
|
||
function UnconnectedMyComponent( | ||
// The resulting type will include: |
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.
Should we add the stuff about the ref
?
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.
Pushed some changes in cb34385, let me know what you think!
Main changes:
- moved down the point re. making sure that there's a name export
- added a new point re. ref forwarding (either via
forwardRef
or viacontextConnect
) - updated index of remaining points as needed
Maybe update the section with |
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.
🚀
Good point. I was kind of on the fence about showing the |
I've updated the point about the
Let's go with showing the extra snippet in the StoryBook docs, for now. As you say, these snippets can offer a more complete example (with Also, sometimes the dynamic code snippet from StoryBook are not as helpful (e.g. sometimes they show |
fe0646f
to
da279b7
Compare
What?
WordPressComponentProps
Why?
Iteratively improve the TypeScript migration guidelines as we gather insights from the initial work on the matter