Skip to content

Commit d1f7e80

Browse files
authored
Improve wording for the "Typing query and mutation endpoints" section of the docs (#1371)
- added a case when `query` doesn't have parameter - added a case when `query` has an optional parameter
1 parent b185725 commit d1f7e80

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/rtk-query/usage-with-typescript.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ const api = createApi({
202202
}
203203
```
204204
- `QueryArg` - The type of the input that will be passed as the only parameter to the `query` property of the endpoint, or the first parameter of a `queryFn` property if used instead.
205+
- If `query` doesn't have a parameter, then `void` type has to be provided explicitly.
206+
- If `query` has an optional parameter, then a union type with the type of parameter, and `void` has to be provided, e.g. `number | void`.
205207

206208
```ts title="Defining endpoints with TypeScript"
207209
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'

0 commit comments

Comments
 (0)