-
Notifications
You must be signed in to change notification settings - Fork 406
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
fix(store): do not infer T from argument to patch #1806
fix(store): do not infer T from argument to patch #1806
Conversation
@markwhitfeld Some questions in order to author a full PR-
|
@david-shortman Thank you for this PR! Looking good. Please ping me when you take it out of draft. Answers to your questions:
PS. I see that that |
|
PS, regarding 2, can TS snippet check the type inferred (and therefore the intellisense auto-completion) for an argument at a call site. I would be amazed if any tool could test this crazy requirement! |
PPS. Amazing article by the way! |
|
||
export function compose<T>(...operators: StateOperator<T>[]): StateOperator<T> { | ||
export function compose<T>(...operators: NoInfer<StateOperator<T>[]>): StateOperator<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sometimes, Typescript was happier about the inferred internals of the function when wrapping NoInfer
around the entire parameter type. other times, it was happier only wrapping T
. so I have implemented a mixture with the principle being whatever results in the smallest code change for correct inference.
df58d31
to
03deb07
Compare
03deb07
to
7776099
Compare
const theOperatorOrValue = operatorOrValue as T | StateOperator<T>; | ||
if (isStateOperator(theOperatorOrValue)) { | ||
value = theOperatorOrValue(existing[index] as Readonly<T>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typescript will not narrow the type correctly, so I had to assert the type of operatorOrValue
first.
@markwhitfeld The build is outputting an error that is not present in my IDE. When I put the relevant code into a TS playground using the same TS version as the repo, 3.9.7, there is also no error: playground. Build error:
This same problem (build outputs error that is not reproducible in playground) occurs several times in the build. |
@david-shortman Thank you for your thorough updates to this PR. |
@david-shortman I have fixed the build issues, but this lead to discovering another crazy typings challenge with the |
This reverts commit 8834f50. (This has been reverted as part of pushing a patch release out with no new features)
(This has been reverted as part of pushing a patch release out with no new features)
This reverts commit 8834f50. (This has been reverted as part of pushing a patch release out with no new features)
(This has been reverted as part of pushing a patch release out with no new features)
This reverts commit 8834f50. (This has been reverted as part of pushing a patch release out with no new features)
)"" This reverts commit 34f3973.
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@ngxs/form-plugin](https://github.com/ngxs/store) | dependencies | minor | [`3.7.6` -> `3.8.0`](https://renovatebot.com/diffs/npm/@ngxs%2fform-plugin/3.7.6/3.8.0) | | [@ngxs/storage-plugin](https://github.com/ngxs/store) | dependencies | minor | [`3.7.6` -> `3.8.0`](https://renovatebot.com/diffs/npm/@ngxs%2fstorage-plugin/3.7.6/3.8.0) | | [@ngxs/store](https://github.com/ngxs/store) | dependencies | minor | [`3.7.6` -> `3.8.0`](https://renovatebot.com/diffs/npm/@ngxs%2fstore/3.7.6/3.8.0) | --- ### Release Notes <details> <summary>ngxs/store</summary> ### [`v3.8.0`](https://github.com/ngxs/store/blob/HEAD/CHANGELOG.md#​380-2023-03-29) [Compare Source](ngxs/store@v3.7.6...v3.8.0) - Feature: Build packages in Ivy format [#​1945](ngxs/store#1945) - Feature: Add advanced selector utilities [#​1824](ngxs/store#1824) - Feature: Expose `ActionContext` and `ActionStatus` [#​1766](ngxs/store#1766) - Feature: `ofAction*` methods should have strong types [#​1808](ngxs/store#1808) - Feature: Improve contextual type inference for state operators [#​1806](ngxs/store#1806) [#​1947](ngxs/store#1947) - Feature: Enable warning on unhandled actions [#​1870](ngxs/store#1870) [#​1951](ngxs/store#1951) - Feature: Router Plugin - Provide more actions and navigation timing option [#​1932](ngxs/store#1932) - Feature: Storage Plugin - Allow providing namespace for keys [#​1841](ngxs/store#1841) - Feature: Storage Plugin - Enable providing storage engine individually [#​1935](ngxs/store#1935) - Feature: Devtools Plugin - Add new options to the `NgxsDevtoolsOptions` interface [#​1879](ngxs/store#1879) - Feature: Devtools Plugin - Add trace options to `NgxsDevtoolsOptions` [#​1968](ngxs/store#1968) - Feature: Form Plugin - Allow `ngxsFormDebounce` to be string [#​1972](ngxs/store#1972) - Performance: Tree-shake patch errors [#​1955](ngxs/store#1955) - Fix: Get descriptor explicitly when it's considered as a class property [#​1961](ngxs/store#1961) - Fix: Avoid delayed updates from state stream [#​1981](ngxs/store#1981) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4yNC41IiwidXBkYXRlZEluVmVyIjoiMzUuMjQuNSJ9--> Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1837 Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information