Skip to content

Commit

Permalink
Revert type tests in createSelector.withTypes.test-d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed Aug 10, 2024
1 parent d7a07ff commit 78c3325
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions type-tests/createSelector.withTypes.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,20 @@ describe('type tests', () => {
// result function are NOT correctly inferred when
// input selectors are provided as separate inline arguments.
createAppSelector(
[
state => {
expectTypeOf(state).toEqualTypeOf(rootState)
state => {

Check failure on line 63 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.7

Parameter 'state' implicitly has an 'any' type.

Check failure on line 63 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.8

Parameter 'state' implicitly has an 'any' type.

Check failure on line 63 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.9

Parameter 'state' implicitly has an 'any' type.

Check failure on line 63 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 5.0

Parameter 'state' implicitly has an 'any' type.
expectTypeOf(state).toEqualTypeOf(rootState)

Check failure on line 64 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.7

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

Check failure on line 64 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.8

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

Check failure on line 64 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.9

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

Check failure on line 64 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 5.0

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

return state.todos
}
],
return state.todos
},
todos => {

Check failure on line 68 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.7

Parameter 'todos' implicitly has an 'any' type.

Check failure on line 68 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.8

Parameter 'todos' implicitly has an 'any' type.

Check failure on line 68 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.9

Parameter 'todos' implicitly has an 'any' type.

Check failure on line 68 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 5.0

Parameter 'todos' implicitly has an 'any' type.
// Known limitation: Parameter types are not inferred in this scenario
expectTypeOf(todos).not.toBeAny()
expectTypeOf(todos).toBeAny()

expectTypeOf(todos).toEqualTypeOf<Todo[]>()
expectTypeOf(todos).not.toEqualTypeOf<Todo[]>()

// @ts-expect-error A typed `createSelector` currently only infers
// the parameter types of the result function when
// input selectors are provided as a single array.
return todos.map(({ id }) => id)
}
)
Expand All @@ -82,32 +83,34 @@ describe('type tests', () => {
// Checking to see if the type of state is correct when multiple
// input selectors are provided as separate inline arguments.
createAppSelector(
[
state => {
expectTypeOf(state).toEqualTypeOf(rootState)
state => {

Check failure on line 86 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.7

Parameter 'state' implicitly has an 'any' type.

Check failure on line 86 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.8

Parameter 'state' implicitly has an 'any' type.

Check failure on line 86 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.9

Parameter 'state' implicitly has an 'any' type.

Check failure on line 86 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 5.0

Parameter 'state' implicitly has an 'any' type.
expectTypeOf(state).toEqualTypeOf(rootState)

Check failure on line 87 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.7

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

Check failure on line 87 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.8

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

Check failure on line 87 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.9

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

Check failure on line 87 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 5.0

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

return state.todos
},
state => {
expectTypeOf(state).toEqualTypeOf(rootState)
return state.todos
},
state => {

Check failure on line 91 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.7

Parameter 'state' implicitly has an 'any' type.

Check failure on line 91 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.8

Parameter 'state' implicitly has an 'any' type.

Check failure on line 91 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.9

Parameter 'state' implicitly has an 'any' type.

Check failure on line 91 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 5.0

Parameter 'state' implicitly has an 'any' type.
expectTypeOf(state).toEqualTypeOf(rootState)

Check failure on line 92 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.7

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

Check failure on line 92 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.8

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

Check failure on line 92 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.9

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

Check failure on line 92 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 5.0

Argument of type 'RootState' is not assignable to parameter of type 'Mismatch'.

return state.alerts
}
],
return state.alerts
},
(todos, alerts) => {

Check failure on line 96 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.7

Parameter 'todos' implicitly has an 'any' type.

Check failure on line 96 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.7

Parameter 'alerts' implicitly has an 'any' type.

Check failure on line 96 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.8

Parameter 'todos' implicitly has an 'any' type.

Check failure on line 96 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.8

Parameter 'alerts' implicitly has an 'any' type.

Check failure on line 96 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.9

Parameter 'todos' implicitly has an 'any' type.

Check failure on line 96 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.9

Parameter 'alerts' implicitly has an 'any' type.

Check failure on line 96 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 5.0

Parameter 'todos' implicitly has an 'any' type.

Check failure on line 96 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 5.0

Parameter 'alerts' implicitly has an 'any' type.
// Known limitation: Parameter types are not inferred in this scenario
expectTypeOf(todos).not.toBeAny()
expectTypeOf(todos).toBeAny()

expectTypeOf(alerts).not.toBeAny()
expectTypeOf(alerts).toBeAny()

// @ts-expect-error A typed `createSelector` currently only infers
// the parameter types of the result function when
// input selectors are provided as a single array.
return todos.map(({ id }) => id)
}
)
})

test('can annotate parameter types of the result function to workaround type inference issue', () => {
createAppSelector([state => state.todos], todos =>
todos.map(({ id }) => id)
createAppSelector(
state => state.todos,

Check failure on line 112 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.7

Parameter 'state' implicitly has an 'any' type.

Check failure on line 112 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.8

Parameter 'state' implicitly has an 'any' type.

Check failure on line 112 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 4.9

Parameter 'state' implicitly has an 'any' type.

Check failure on line 112 in type-tests/createSelector.withTypes.test-d.ts

View workflow job for this annotation

GitHub Actions / Test Types with TypeScript 5.0

Parameter 'state' implicitly has an 'any' type.
(todos: Todo[]) => todos.map(({ id }) => id)
)
})
})
Expand Down

0 comments on commit 78c3325

Please sign in to comment.