Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

BaseQueryNarrowing.md

35 lines1.9 KB

1---
2id: BaseQueryNarrowing
3title: BaseQueryNarrowing
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8Defined in: [packages/angular-query-experimental/src/types.ts:80](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L80)
9​
10The `isSuccess`/`isError`/`isPending` methods on a query result. Unlike `react-query`'s derived booleans,
11these are type-guard methods you call β€” `if (query.isSuccess())` β€” so that `query.data` narrows away
12`undefined` inside the branch, the same way `status` narrowing works on the plain object `react-query`
13returns.
14​
15## Type Parameters
16​
17### TData
18​
19`TData` = `unknown`
20​
21The type `data` ends up as after `select` runs.
22​
23### TError
24​
25`TError` = [`DefaultError`](../type-aliases/DefaultError.md)
26​
27The type of errors your `queryFn` may throw.
28​
29## Properties
30​
31| Property | Type | Description |
32| ------ | ------ | ------ |
33| <a id="property-iserror"></a> `isError` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult<TData, TError, CreateStatusBasedQueryResult<"error", TData, TError>>` | Returns `true` if the query is in the `error` state, narrowing the result to that state. |
34| <a id="property-ispending"></a> `isPending` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult<TData, TError, CreateStatusBasedQueryResult<"pending", TData, TError>>` | Returns `true` if the query is in the `pending` state, narrowing the result to that state. |
35| <a id="property-issuccess"></a> `isSuccess` | (`this`: [`CreateBaseQueryResult`](../type-aliases/CreateBaseQueryResult.md)\<`TData`, `TError`\>) => `this is CreateBaseQueryResult<TData, TError, CreateStatusBasedQueryResult<"success", TData, TError>>` | Returns `true` if the query is in the `success` state, narrowing the result to that state. |