Replies: 1 comment
-
No this is not a bug, without going into depth it looks correct. The problem here is that
...
user = derivedAsync(() => this.getUser(+this.id()).result$, {
initialValue: {
...createPendingObserverResult<User>(),
isFetchNextPageError: false,
isFetchPreviousPageError: false,
fetchNextPage: () => Promise.resolve({}), // these will throw an error, since the type is a bit more intricate then just a generic resolve
fetchPreviousPage: () => Promise.resolve({}),
// ... and the 4 more that i cant see right now ...
} satisfies InfiniteQueryObserverResult<User>, // satisfies becuase we do not want to change the resulting type but get the type checking on it
});
... This is one way to do it, if you think that this is too much work for something that simple then its wise to choose to disable type-checking here (with ...
user = derivedAsync<InfiniteQueryObserverResult<InfiniteData<{previousId: number, nextId: number, data: User}>>>(() => this.getUser(+this.id()).result$, {
initialValue: createPendingObserverResult<User>() as any,
});
... Please be careful with the latter approach, since you're missing some properties that probably are used by your application before they're ready. A wise descision would be to mix both together: add the missing properties and then disable the type-checking with |
Beta Was this translation helpful? Give feedback.
-
Hey @NetanelBasal, @luii :
I attempted to use signals with ngneat/query and encountered a TypeScript error in the following code:
The error message is:
Is this a bug, or am I using it incorrectly? If the latter, how can I fix it?
Here is the full code example:
StackBlitz Example
Beta Was this translation helpful? Give feedback.
All reactions