Skip to content

Commit f9f85c7

Browse files
authored
add TS 4.3 to test matrix, disable strictOptionalProperties for TS4.4 (#1137)
* add TS 4.3 to test matrix, disable `strictOptionalProperties` for TS4.4 * tweaks * comment * add any cast in error cases for TS 4.4
1 parent b3eee1c commit f9f85c7

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
fail-fast: false
7979
matrix:
8080
node: ['14.x']
81-
ts: ['3.9', '4.0', '4.1', '4.2', 'next']
81+
ts: ['3.9', '4.0', '4.1', '4.2', '4.3', 'next']
8282
steps:
8383
- name: Checkout repo
8484
uses: actions/checkout@v2
@@ -110,6 +110,10 @@ jobs:
110110
if: ${{ matrix.ts < 4.1 }}
111111
run: sed -i -e 's/@pre41-ts-ignore/@ts-ignore/' -e '/pre41-remove-start/,/pre41-remove-end/d' ./src/tests/*.* ./src/query/tests/*.ts*
112112

113+
- name: 'disable strictOptionalProperties'
114+
if: ${{ matrix.ts == 'next' }}
115+
run: sed -i -e 's|//\(.*strictOptionalProperties.*\)$|\1|' tsconfig.base.json
116+
113117
- name: Test types
114118
run: |
115119
./node_modules/.bin/tsc --version

src/createAsyncThunk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ If you want to use the AbortController to react to \`abort\` events, please cons
604604
finalAction =
605605
err instanceof RejectWithValue
606606
? rejected(null, requestId, arg, err.payload, err.meta)
607-
: rejected(err, requestId, arg)
607+
: rejected(err as any, requestId, arg)
608608
}
609609
// We dispatch the result action _after_ the catch, to avoid having any errors
610610
// here get swallowed by the try/catch block,

src/query/core/module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ declare module '../apiTypes' {
121121
ThunkDispatch<any, any, AnyAction>
122122
>
123123
/**
124-
* TODO
124+
* A collection of utility thunks for various situations.
125125
*/
126126
util: {
127127
/**
@@ -130,7 +130,7 @@ declare module '../apiTypes' {
130130
* The thunk accepts three arguments: the name of the endpoint we are updating (such as `'getPost'`), any relevant query arguments, and a set of options used to determine if the data actually should be re-fetched based on cache staleness.
131131
*
132132
* React Hooks users will most likely never need to use this directly, as the `usePrefetch` hook will dispatch this thunk internally as needed when you call the prefetching function supplied by the hook.
133-
*
133+
*
134134
* @example
135135
*
136136
* ```ts no-transpile

src/tests/createAsyncThunk.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ describe('createAsyncThunk', () => {
323323
try {
324324
throw error
325325
} catch (err) {
326-
if (!err.response) {
326+
if (!(err as any).response) {
327327
throw err
328328
}
329329
return rejectWithValue(errorPayload)

src/tests/createAsyncThunk.typetest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const anyAction = { type: 'foo' } as AnyAction
163163
)
164164
return result.data.data
165165
} catch (err) {
166-
let error: AxiosError<ErrorFromServer> = err // cast for access to AxiosError properties
166+
let error: AxiosError<ErrorFromServer> = err as any // cast for access to AxiosError properties
167167
if (!error.response) {
168168
// let it be handled as any other unknown error
169169
throw err

tsconfig.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"rootDir": "./src",
1111
// stricter type-checking for stronger correctness. Recommended by TS
1212
"strict": true,
13+
// "strictOptionalProperties": false, // disable strictOptionalProperties for now to also build with 4.4
1314
// linter checks for common issues
1415
"noImplicitReturns": true,
1516
"noFallthroughCasesInSwitch": true,

0 commit comments

Comments
 (0)