diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 42c692db74..4adccddf65 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -106,7 +106,7 @@ jobs: fail-fast: false matrix: node: ['20.x'] - ts: ['4.7', '4.8', '4.9', '5.0', '5.1', '5.2', '5.3'] + ts: ['4.7', '4.8', '4.9', '5.0', '5.1', '5.2', '5.3', '5.4'] steps: - name: Checkout repo uses: actions/checkout@v4 diff --git a/package.json b/package.json index e454324c89..d8606e8cd5 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "release-it": "^14.12.5", "serve": "^14.2.0", "ts-node": "^10.9.2", - "typescript": "^5.2.2" + "typescript": "^5.4.3" }, "resolutions": { "esbuild": "0.19.7", diff --git a/packages/toolkit/package.json b/packages/toolkit/package.json index 717cba2305..2c40556fcd 100644 --- a/packages/toolkit/package.json +++ b/packages/toolkit/package.json @@ -90,7 +90,7 @@ "tslib": "^1.10.0", "tsup": "^7.2.0", "tsx": "^3.12.2", - "typescript": "^5.3.3", + "typescript": "^5.4.5", "vite-tsconfig-paths": "^4.3.1", "vitest": "^1.1.3", "yargs": "^15.3.1" diff --git a/packages/toolkit/src/createAsyncThunk.ts b/packages/toolkit/src/createAsyncThunk.ts index f384ab9af2..e7ee39a05a 100644 --- a/packages/toolkit/src/createAsyncThunk.ts +++ b/packages/toolkit/src/createAsyncThunk.ts @@ -116,7 +116,7 @@ export const miniSerializeError = (value: any): SerializedError => { export type AsyncThunkConfig = { state?: unknown - dispatch?: Dispatch + dispatch?: ThunkDispatch extra?: unknown rejectValue?: unknown serializedErrorType?: unknown @@ -240,7 +240,7 @@ export type AsyncThunkAction< ThunkArg, ThunkApiConfig extends AsyncThunkConfig, > = ( - dispatch: GetDispatch, + dispatch: NonNullable>, getState: () => GetState, extra: GetExtra, ) => SafePromise< @@ -577,7 +577,7 @@ export const createAsyncThunk = /* @__PURE__ */ (() => { function actionCreator( arg: ThunkArg, - ): AsyncThunkAction { + ): AsyncThunkAction> { return (dispatch, getState, extra) => { const requestId = options?.idGenerator ? options.idGenerator(arg) diff --git a/packages/toolkit/src/tests/createReducer.test-d.ts b/packages/toolkit/src/tests/createReducer.test-d.ts index 535710a256..cfc0c899fb 100644 --- a/packages/toolkit/src/tests/createReducer.test-d.ts +++ b/packages/toolkit/src/tests/createReducer.test-d.ts @@ -43,10 +43,13 @@ describe('type tests', () => { // @ts-expect-error createReducer(0 as number, (builder) => { - // @ts-expect-error - builder - .addCase('increment', incrementHandler) - .addCase('decrement', decrementHandler) + expectTypeOf(builder.addCase) + .parameter(1) + .not.toMatchTypeOf(incrementHandler) + + expectTypeOf(builder.addCase) + .parameter(1) + .not.toMatchTypeOf(decrementHandler) }) }) diff --git a/yarn.lock b/yarn.lock index 62f59f6a2d..ded1d18947 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7488,7 +7488,7 @@ __metadata: tslib: "npm:^1.10.0" tsup: "npm:^7.2.0" tsx: "npm:^3.12.2" - typescript: "npm:^5.3.3" + typescript: "npm:^5.4.5" vite-tsconfig-paths: "npm:^4.3.1" vitest: "npm:^1.1.3" yargs: "npm:^15.3.1" @@ -25733,7 +25733,7 @@ __metadata: release-it: "npm:^14.12.5" serve: "npm:^14.2.0" ts-node: "npm:^10.9.2" - typescript: "npm:^5.2.2" + typescript: "npm:^5.4.3" languageName: unknown linkType: soft @@ -28334,6 +28334,26 @@ __metadata: languageName: node linkType: hard +"typescript@npm:^5.4.3": + version: 5.4.3 + resolution: "typescript@npm:5.4.3" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/de4c69f49a7ad4b1ea66a6dcc8b055ac34eb56af059a069d8988dd811c5e649be07e042e5bf573e8d0ac3ec2f30e6c999aa651cd09f6e9cbc6113749e8b6be20 + languageName: node + linkType: hard + +"typescript@npm:^5.4.5": + version: 5.4.5 + resolution: "typescript@npm:5.4.5" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/d04a9e27e6d83861f2126665aa8d84847e8ebabcea9125b9ebc30370b98cb38b5dff2508d74e2326a744938191a83a69aa9fddab41f193ffa43eabfdf3f190a5 + languageName: node + linkType: hard + "typescript@npm:~4.2.4": version: 4.2.4 resolution: "typescript@npm:4.2.4" @@ -28384,6 +28404,26 @@ __metadata: languageName: node linkType: hard +"typescript@patch:typescript@npm%3A^5.4.3#optional!builtin": + version: 5.4.3 + resolution: "typescript@patch:typescript@npm%3A5.4.3#optional!builtin::version=5.4.3&hash=d69c25" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/3abea475798fdf7ee46e75dafc50c85f30fd1e7061559ec2af61646f23d16c91742703f04f0ac55be52f58ca05c02f77404b7b94bbad16278c9a54c9eeb4f4ea + languageName: node + linkType: hard + +"typescript@patch:typescript@npm%3A^5.4.5#optional!builtin": + version: 5.4.5 + resolution: "typescript@patch:typescript@npm%3A5.4.5#optional!builtin::version=5.4.5&hash=d69c25" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/584be8bac7112ad49a9eb9992f71d542b1ff2fafb5bb315e1c196145e8feab589f1d7223cfb2d5df6770789582e6918f8287d1f2f89911b38eb80e29c560ad00 + languageName: node + linkType: hard + "typescript@patch:typescript@npm%3A~4.2.4#optional!builtin": version: 4.2.4 resolution: "typescript@patch:typescript@npm%3A4.2.4#optional!builtin::version=4.2.4&hash=334f98"