-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Switch to Variadic Tuple Types for reducers and selectors #2715
Comments
I'm interested in helping add the types. Would want to know how I should go about this since the repo doesn't currently use 4.0+ yet. |
Issue with switching |
So the problem I was having in #2905 is that typescript doesn't seem to interpret variadic tuple type with strict order. It just creates a basic union type for all elements in the array. Instead, Typescript came up with a definition like this for the following: /* derived:
export function createSelector<Selector<any, any>[], any>(
...args: Selector<any, any> | ((...args: any[]) => any)[]):
MemoizedSelector<any, any, DefaultProjectorFn<any>>
*/
const selector = createSelector(
incrementOne,
incrementTwo,
(state: any, props: any) => props.value,
projectFn
); A very simple example of my expectations vs reality: type NumberArray = number[];
type StringArray = string[];
// I'd like a type that is a tuple of a variadic number of numbers followed by a variadic number of string
type Combined = [...numbers: NumberArray, ...strings: StringArray];
function thing(...args: Combined) {
return 3;
}
thing('5', 5); // this should result in an error, right? |
...And now I see a comment from Alex in #2894 mentioning microsoft/TypeScript#41544 and that might be the fix needed to get the kind of type desired for |
Can we make a checklist of what still needs to be converted? Happy to help get items done. |
Describe any alternatives/workarounds you're currently using
Angular release 10.1 added TS 4.0 support (https://github.com/angular/angular/blob/master/CHANGELOG.md#1010-2020-09-02) so we'd want to get that as well. This will enable us to use Variadic Tuple Types.
Other information:
If accepted, I would be willing to submit a PR for this feature
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered: