-
-
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
Selectors: typed projector methods #3571
Labels
15.x
Accepting PRs
Breaking Change
community watch
Someone from the community is working this issue/PR
Project: Store
Comments
2 tasks
3 tasks
Started a PR, feel free to assign |
timdeschryver
added
Accepting PRs
community watch
Someone from the community is working this issue/PR
labels
Sep 19, 2022
Repository owner
moved this from In Progress
to Done
in NgRx v15
Nov 2, 2022
brandonroberts
pushed a commit
that referenced
this issue
Nov 2, 2022
BREAKING CHANGE: The projector function on the selector is type-safe by default. BEFORE: The projector is not type-safe by default, allowing for potential mismatch types in the projector function. ```ts const mySelector = createSelector( () => 'one', () => 2, (one, two) => 3 ) mySelector.projector() // <- type is projector(...args: any[]): number ``` AFTER: The projector is strict by default, but can be bypassed with an `any` generic parameter. ```ts const mySelector = createSelector( () => 'one', () => 2, (one, two) => 3 ) mySelector.projector() // <- Results in type error. Type is projector(s1: string, s2: number): number ``` To retain previous behavior ```ts const mySelector = createSelector( () => 'one', () => 2, (one, two) => 3 ) (mySelector.projector as any)() ``` Closes #3571
3 tasks
brandonroberts
pushed a commit
that referenced
this issue
Nov 2, 2022
BREAKING CHANGE: The projector method has become strict BEFORE: You could pass any arguments to the projector method const selector = createSelector( selectString, // returning a string selectNumber, // returning a number (s, n, prefix: string) => { return prefix + s.repeat(n); } ) // you could pass any argument selector.projector(1, 'a', true); AFTER: const selector = createSelector( selectString, // returning a string selectNumber, // returning a number (s, n, prefix: string) => { return prefix + s.repeat(n); } ) // this throws selector.projector(1, 'a', true); // this does not throw because the arguments have the correct type selector.projector(1, 'a', 'prefix'); Closes #3571
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
15.x
Accepting PRs
Breaking Change
community watch
Someone from the community is working this issue/PR
Project: Store
Information
This issue comes from a discussion #3097
Currently when using the
selector.projector
method, we can pass it any argument(s) and it won't complain. With this change we want to make the projectors type-safe so that mistakes can be caught earlier.Describe any alternatives/workarounds you're currently using
/
I would be willing to submit a PR to fix this issue
The text was updated successfully, but these errors were encountered: