Skip to content

Commit 78c3325

Browse files
committed
Revert type tests in createSelector.withTypes.test-d.ts
1 parent d7a07ff commit 78c3325

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

type-tests/createSelector.withTypes.test-d.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,20 @@ describe('type tests', () => {
6060
// result function are NOT correctly inferred when
6161
// input selectors are provided as separate inline arguments.
6262
createAppSelector(
63-
[
64-
state => {
65-
expectTypeOf(state).toEqualTypeOf(rootState)
63+
state => {
64+
expectTypeOf(state).toEqualTypeOf(rootState)
6665

67-
return state.todos
68-
}
69-
],
66+
return state.todos
67+
},
7068
todos => {
7169
// Known limitation: Parameter types are not inferred in this scenario
72-
expectTypeOf(todos).not.toBeAny()
70+
expectTypeOf(todos).toBeAny()
7371

74-
expectTypeOf(todos).toEqualTypeOf<Todo[]>()
72+
expectTypeOf(todos).not.toEqualTypeOf<Todo[]>()
7573

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

89-
return state.todos
90-
},
91-
state => {
92-
expectTypeOf(state).toEqualTypeOf(rootState)
89+
return state.todos
90+
},
91+
state => {
92+
expectTypeOf(state).toEqualTypeOf(rootState)
9393

94-
return state.alerts
95-
}
96-
],
94+
return state.alerts
95+
},
9796
(todos, alerts) => {
9897
// Known limitation: Parameter types are not inferred in this scenario
99-
expectTypeOf(todos).not.toBeAny()
98+
expectTypeOf(todos).toBeAny()
10099

101-
expectTypeOf(alerts).not.toBeAny()
100+
expectTypeOf(alerts).toBeAny()
102101

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

108110
test('can annotate parameter types of the result function to workaround type inference issue', () => {
109-
createAppSelector([state => state.todos], todos =>
110-
todos.map(({ id }) => id)
111+
createAppSelector(
112+
state => state.todos,
113+
(todos: Todo[]) => todos.map(({ id }) => id)
111114
)
112115
})
113116
})

0 commit comments

Comments
 (0)