Skip to content

Commit

Permalink
Merge pull request #4623 from reduxjs/feature/5.0-tooling-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Nov 23, 2023
2 parents c9e0650 + 2b7af71 commit dae0da7
Show file tree
Hide file tree
Showing 6 changed files with 605 additions and 553 deletions.
52 changes: 29 additions & 23 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['16.x']
node: ['18.x']

steps:
- name: Checkout repo
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: ['16.x']
node: ['18.x']
steps:
- name: Checkout repo
uses: actions/checkout@v2
Expand Down Expand Up @@ -99,8 +99,8 @@ jobs:
strategy:
fail-fast: false
matrix:
node: ['16.x']
ts: ['4.7', '4.8', '4.9', '5.0']
node: ['18.x']
ts: ['4.7', '4.8', '4.9', '5.0', '5.1', '5.2', '5.3']
steps:
- name: Checkout repo
uses: actions/checkout@v2
Expand Down Expand Up @@ -132,6 +132,28 @@ jobs:
yarn test:typecheck
yarn test:types
are-the-types-wrong:
name: Check package config with are-the-types-wrong

needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['18.x']
steps:
- name: Checkout repo
uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: package
path: .

# Note: We currently expect "FalseCJS" failures for Node16 + `moduleResolution: "node16"
- name: Run are-the-types-wrong
run: npx @arethetypeswrong/cli ./package.tgz --format table --ignore-rules false-cjs

test-published-artifact:
name: Test Published Artifact ${{ matrix.example }}

Expand All @@ -140,17 +162,8 @@ jobs:
strategy:
fail-fast: false
matrix:
node: ['16.x']
example:
[
'cra4',
'cra5',
'next',
'vite',
'node-standard',
'node-esm',
'are-the-types-wrong'
]
node: ['18.x']
example: ['cra4', 'cra5', 'next', 'vite', 'node-standard', 'node-esm']
steps:
- name: Checkout repo
uses: actions/checkout@v2
Expand Down Expand Up @@ -190,15 +203,8 @@ jobs:

- name: Build example
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: yarn build
run: NODE_OPTIONS=--openssl-legacy-provider yarn build

- name: Run test step
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: yarn test
if: matrix.example != 'are-the-types-wrong'

- name: Run test step
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
# Ignore "FalseCJS" errors in the `attw` job
run: yarn test -n FalseCJS
if: matrix.example == 'are-the-types-wrong'
3 changes: 2 additions & 1 deletion errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"13": "The slice reducer for key \"\" returned undefined when probed with a random type. Don't try to handle '' or other actions in \"redux/*\" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.",
"14": "When called with an action of type , the slice reducer for key \"\" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.",
"15": "Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.",
"16": "bindActionCreators expected an object or a function, but instead received: ''. Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?"
"16": "bindActionCreators expected an object or a function, but instead received: ''. Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?",
"17": "Action \"type\" property must be a string. Instead, the actual type was: ''. Value was: '' (stringified)"
}
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ignore = "git diff --quiet HEAD^ HEAD -- ../docs/ ."

[build.environment]
NODE_VERSION = "16.14.0"
NODE_VERSION = "18.15.0"
NODE_OPTIONS = "--max_old_space_size=4096"
NETLIFY_USE_YARN = "true"
YARN_VERSION = "1.22.10"
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"rxjs": "^7.5.6",
"tsup": "^6.7.0",
"typescript": "^4.8.3",
"vitest": "^0.27.2"
"tsup": "7.0.0",
"typescript": "5.2",
"vitest": "^0.34.0"
},
"resolutions": {
"esbuild": "0.19.7"
},
"sideEffects": false
}
52 changes: 22 additions & 30 deletions test/typescript/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ const storeWithPreloadedState: Store<State> = createStore(reducer, {
b: { c: 'c', d: 'd' },
e: brandedString
})
// @ts-expect-error
const storeWithBadPreloadedState: Store<State> = createStore(reducer, {
b: { c: 'c' },
e: brandedString
})

const storeWithBadPreloadedState: Store<State> =
// @ts-expect-error
// prettier-ignore
createStore(reducer, { b: { c: 'c' }, e: brandedString })

const reducerA: Reducer<string> = (state = 'a') => state
const reducerB: Reducer<{ c: string; d: string }> = (
Expand All @@ -91,14 +91,11 @@ const storeWithCombineReducer = createStore(combinedReducer, {
b: { c: 'c', d: 'd' },
e: brandedString
})
// @ts-expect-error
const storeWithCombineReducerAndBadPreloadedState = createStore(
combinedReducer,
{
b: { c: 'c' },
e: brandedString
}
)

const storeWithCombineReducerAndBadPreloadedState =
// @ts-expect-error
// prettier-ignore
createStore( combinedReducer, { b: { c: 'c' }, e: brandedString } )

const nestedCombinedReducer = combineReducers({
a: (state: string = 'a') => state,
Expand All @@ -120,10 +117,10 @@ const simpleCombinedReducer = combineReducers({
d: (state: string = 'd') => state
})

// @ts-expect-error
const storeWithSimpleCombinedReducer = createStore(simpleCombinedReducer, {
c: 5
})
const storeWithSimpleCombinedReducer =
// @ts-expect-error
// prettier-ignore
createStore(simpleCombinedReducer, { c: 5 })

// Note: It's not necessary that the errors occur on the lines specified, just as long as something errors somewhere
// since the preloaded state doesn't match the reducer type.
Expand All @@ -133,11 +130,10 @@ const simpleCombinedReducerWithImplicitState = combineReducers({
d: (state = 'd') => state
})

// @ts-expect-error
const storeWithSimpleCombinedReducerWithImplicitState = createStore(
simpleCombinedReducerWithImplicitState,
{ c: 5 }
)
const storeWithSimpleCombinedReducerWithImplicitState =
// @ts-expect-error
// prettier-ignore
createStore( simpleCombinedReducerWithImplicitState, { c: 5 } )

const storeWithActionReducer = createStore(reducerWithAction)
const storeWithActionReducerAndPreloadedState = createStore(reducerWithAction, {
Expand All @@ -148,14 +144,10 @@ const storeWithActionReducerAndPreloadedState = createStore(reducerWithAction, {
funcWithStore(storeWithActionReducer)
funcWithStore(storeWithActionReducerAndPreloadedState)

// @ts-expect-error
const storeWithActionReducerAndBadPreloadedState = createStore(
reducerWithAction,
{
b: { c: 'c' },
e: brandedString
}
)
const storeWithActionReducerAndBadPreloadedState =
// @ts-expect-error
// prettier-ignore
createStore( reducerWithAction, { b: { c: 'c' }, e: brandedString } )

const enhancer: StoreEnhancer = next => next

Expand Down
Loading

0 comments on commit dae0da7

Please sign in to comment.