Better typings for dataPersistence #4108
Labels
community
This is a good first issue for contributing
outdated
scope: angular
Issues related to Angular support in Nx
stale
type: enhancement
Uh oh!
There was an error while loading. Please reload this page.
Problems
state
ondataPersistence
callbacks is nullable.nx/packages/angular/src/runtime/nx/data-persistence.ts
Lines 36 to 40 in 8e519cd
nx/packages/angular/src/runtime/nx/data-persistence.ts
Lines 75 to 76 in 8e519cd
With strict type enabled, we can't use the state directly without checking its nullability before. Ex:
void
;Action
orObservable<Action>
.Note that currently I can write something like this:
... without type errors :(. It would be awesome if we conditionally defined the correct type to avoid mistakes like this.
nx/packages/angular/src/runtime/nx/data-persistence.ts
Lines 306 to 307 in 8e519cd
"[...] and forces the developer to handle errors [...]"
... however the
onError
is optional. Maybe I just misunderstood the sentence?any
tounknown
inonError
, in order to avoid some typos, while accessing props. Somewhat related to Error in catch clause should be unknown microsoft/TypeScript#26174.Suggestions
For the points 1, 3 and 4, I got this idea (not sure if it's the best way, but...):
Environment
Angular 10
Ngrx 10
NX 10
The text was updated successfully, but these errors were encountered: