Skip to content

Commit

Permalink
Reformat typetests to handle mismatched TS 4.x/5.x error locations
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Nov 23, 2023
1 parent 9501bc4 commit c609eb7
Showing 1 changed file with 22 additions and 30 deletions.
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

0 comments on commit c609eb7

Please sign in to comment.