-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
Button
component to TypeScript (#46997)
* Rename button/index.js to .jsx * Possible approach to the prop types * Simplify the tag container * Allow passing childrent to TagElement * Fix the type of onKeyDown * Rename test/index.js to .tsx, fix some errors * Fix an eslint error from children being defined in the outer scope * Rename stories/index.js to .tsx, add type annotations * Alphabetize types.ts types * Refactor TagElement to element * Alphabetize an import * Revert changes to element, this will fail type checking * Use the [] array type syntax * Improve the typing of hasChildren * Fix the typing of chilren.length * Revert "Revert changes to element, this will fail type checking" This reverts commit 0b616c7. * Pass the generic of WordPressComponentProps a second argument * Don't destructure out children, simply let them be in props * Use React.MousEvent * Update README.md with types from types.ts * Fix the type of shortcut * Remove unnecessary Type annotations * In README.md, alphabetize the props * Add a Required annotation to the variant prop * Add a JS DocBlock to Button * Add a CHANGELOG entry * Commit Lena's suggestion: Update packages/components/src/button/types.ts Co-authored-by: Lena Morita <[email protected]> * Commit Lena's suggestion: Update packages/components/src/button/deprecated.tsx Co-authored-by: Lena Morita <[email protected]> * Commit Lena's suggestion: Update packages/components/src/button/index.tsx Co-authored-by: Lena Morita <[email protected]> * Apply Lena's suggestion to change 'div' to 'button' Also, correct some typing errors. * Remvoe needless type DisabledEvent * Remove needless argTypes that Storybook will infer from types * Restore a deleted test, thanks to Lena's idea As Lena mentioned, the intent of this test looks like ensuring that additional props are passed to the element. * Don't expect the console to error * Update tooltipPosition in README.md * Move the CHANGELOG entry to Unreleased * Cherry-pick @mirka 's commit to make Button types specific to a or button * Commit Lena's static tests verbatim #46997 (review) * Fix a failed test run that I caused * Rename CommonButtonProps to BaseButtonProps * Commit Lena's suggestion: Update packages/components/src/button/stories/index.tsx Co-authored-by: Lena Morita <[email protected]> * Commit Lena's diff for static typing test Co-authored-by: Lena Morita <[email protected]>
- Loading branch information
Showing
16 changed files
with
447 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.