-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[typescript] Constrain props type param appropriately in withStyles, …
…withTheme, withWidth HOCs (#11003) * Rewrite withStyles definition, using Omit My experience is that the current `withStyles` declaration works poorly with Typescript 2.8. I'm not sure that it's the compiler version that's the issue, though. At least in my usage, it fails to remove `WithStyles<ClassKey>` from the return type. This definition works better in my experience, doesn't rely on subtle inferencer behavior in the same way, and seems to be in the mainstream of current usage. There's a built-in `Exclude` function in Typescript 2.8 that does what `Omit` does. I used `Omit` for compatibility with older compilers. * Fix test issues; redesign withTheme, withWidth using Omit also. * Use preferred style in tests * Remove another inferrable generic parameter from test. * Remove another inferrable generic parameter from test. * Make inclusion of WithStyles in the innerComponent's type def optional. * Commit for review and suggestions; DOES NOT COMPILE. Remove commented-on code from withStyles; use ConsistentWith typewrapper; add SFC test for withWidth add FAILING test for doc scenario 2 (withStyles of union) * Redefine with* to remove Omit. Trim obsolete doc. Rename "decorate" function to "withMyStyles" in doc. Remove redundant failing tests added to clarify Omit problem. * Bring back explicit generic parameter on union case in test, doc. In package.json, up-rev Typescript to >2.6.2, and print Typescript version in "typescript" run command. * Rename withMyStyles back to decorate. Use single quotes in test. In package.json, revert typescript to 2.6.1, remove version-printing run command In package.lock, revert typescript to 2.6.1. * Add trailing comma to function params in styling-comparison test. * Fix package.json, yarn.lock. * Remove newline from typescript doc. * Remove needless Omit imports. * Remove extra explicit from doc, add trailing semicolon to function * Remove comment from styling-comparison.spec.tsx
- Loading branch information
Showing
9 changed files
with
57 additions
and
50 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
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