-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeScript] Preserve the generic signature of getEntityRecord and ge…
…tEntityRecords through currying (#44453) Declare GetEntityRecord as a *callable interface* that is callable as usually, but also ships another signature without the state argument. This works around a TypeScript limitation that doesn't allow currying generic functions: ```ts type CurriedState = F extends ( state: any, ...args: infer P ) => infer R ? ( ...args: P ) => R : F; type Selector = <K extends string | number>( state: any, kind: K, key: K extends string ? 'string value' : false ) => K; type BadlyInferredSignature = CurriedState< Selector > // BadlyInferredSignature evaluates to: // (kind: string number, key: false | "string value") => string number ``` The signature without the state parameter shipped as CurriedSignature is used in the return value of `select( coreStore )`. See #41578 for more details. This commit includes a docgen update to add support for typecasting selectors
- Loading branch information
1 parent
ad37bdd
commit 4a0fbe0
Showing
4 changed files
with
195 additions
and
49 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