Skip to content

Commit 7219d19

Browse files
committed
adjust tests, try to provoke error
1 parent b0b9b8f commit 7219d19

File tree

5 files changed

+31
-44
lines changed

5 files changed

+31
-44
lines changed

.github/workflows/test-codegen.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,18 @@ defaults:
66
run:
77
working-directory: ./packages/rtk-query-codegen-openapi
88

9-
on: [push, pull_request]
9+
on:
10+
push:
11+
branches:
12+
- master
13+
paths:
14+
- 'packages/rtk-query-codegen-openapi/**'
15+
pull_request:
16+
paths:
17+
- 'packages/rtk-query-codegen-openapi/**'
1018

1119
jobs:
12-
changes:
13-
name: Check for changes
14-
runs-on: ubuntu-latest
15-
outputs:
16-
codegen: ${{ steps.filter.outputs.codegen }}
17-
steps:
18-
- uses: actions/checkout@v2
19-
- uses: dorny/paths-filter@v2
20-
id: filter
21-
with:
22-
filters: |
23-
codegen:
24-
- 'packages/rtk-query-codegen-openapi/**'
25-
2620
build:
27-
needs: changes
28-
if: ${{ needs.changes.outputs.codegen == 'true' }}
29-
3021
runs-on: ubuntu-latest
3122

3223
strategy:

.github/workflows/tests.yml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
name: CI
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
- 'packages/toolkit/**'
8+
pull_request:
9+
paths:
10+
- 'packages/toolkit/**'
11+
312
defaults:
413
run:
514
working-directory: ./packages/toolkit
615

716
jobs:
8-
changes:
9-
name: Check for changes
10-
runs-on: ubuntu-latest
11-
outputs:
12-
toolkit: ${{ steps.filter.outputs.toolkit }}
13-
steps:
14-
- uses: actions/checkout@v2
15-
- uses: dorny/paths-filter@v2
16-
id: filter
17-
with:
18-
filters: |
19-
toolkit:
20-
- 'packages/toolkit/**'
21-
2217
build:
23-
needs: changes
24-
if: ${{ needs.changes.outputs.toolkit == 'true' }}
25-
2618
name: Lint, Test, Build & Pack on Node ${{ matrix.node }}
2719

2820
runs-on: ubuntu-latest

packages/toolkit/src/createSlice.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ export type ValidateSliceCaseReducers<
235235
? {
236236
prepare(...a: never[]): Omit<A, 'type'>
237237
}
238-
: ACR[T]
238+
: {}
239+
// this should still error in 4.8 - the fix woule be
240+
// : ACR[T]
239241
}
240242

241243
function getType(slice: string, actionKey: string): string {
@@ -268,8 +270,10 @@ export function createSlice<
268270
typeof process !== 'undefined' &&
269271
process.env.NODE_ENV === 'development'
270272
) {
271-
if(options.initialState === undefined) {
272-
console.error('You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`')
273+
if (options.initialState === undefined) {
274+
console.error(
275+
'You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`'
276+
)
273277
}
274278
}
275279

packages/toolkit/src/tests/createSlice.typetest.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import type {
99
PayloadAction,
1010
SliceCaseReducers,
1111
ValidateSliceCaseReducers,
12-
} from '@reduxjs/toolkit'
13-
import { createAction, createSlice } from '@reduxjs/toolkit'
12+
} from '..'
13+
import { createAction, createSlice } from '..'
1414
import { expectType } from './helpers'
1515

1616
/*
@@ -58,7 +58,7 @@ const value = actionCreators.anyKey
5858
reducers: {
5959
increment: (state: number, action) => {
6060
// @ts-expect-error
61-
expect<string>(state)
61+
expectType<string>(state)
6262
return state + action.payload
6363
},
6464
decrement: (state: number, action) => state - action.payload,
@@ -101,7 +101,7 @@ const value = actionCreators.anyKey
101101
{ payload = 1 }: PayloadAction<number | undefined>
102102
) => {
103103
// @ts-expect-error
104-
expect<string>(state)
104+
expectType<string>(state)
105105
return state - payload
106106
},
107107

packages/toolkit/tsconfig.test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../toolkit/tsconfig.base.json",
2+
"extends": "./tsconfig.base.json",
33
"compilerOptions": {
44
"allowSyntheticDefaultImports": true,
55
"esModuleInterop": true,

0 commit comments

Comments
 (0)