Skip to content

Commit 36604dd

Browse files
committed
chore: update reselect and re-reselect
1 parent a158bda commit 36604dd

17 files changed

+205
-236
lines changed

examples/redux-todos/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
"@types/react-dom": "^17.0.0",
1212
"@types/react-redux": "^7.1.12",
1313
"@types/uuid": "^8.3.0",
14-
"re-reselect": "^4.0.0",
14+
"re-reselect": "^4.0.1",
1515
"react": "^16.13.1",
1616
"react-dom": "^16.13.1",
1717
"react-redux": "^7.2.2",
1818
"redux": "^4.0.5",
19-
"reselect": "^4.0.0",
19+
"reselect": "^4.1.6",
2020
"reselect-utils": "^2.0.0-beta.16",
2121
"typescript-fsa": "^3.0.0",
2222
"typescript-fsa-reducers": "^1.2.2",

packages/eslint-plugin-reselect-utils/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
"build": "yarn clean && yarn build:cjs && yarn build:es"
2323
},
2424
"dependencies": {
25-
"@typescript-eslint/experimental-utils": "^4.17.0"
25+
"@typescript-eslint/experimental-utils": "^5.31.0"
2626
},
2727
"peerDependencies": {
28-
"@typescript-eslint/parser": "^4.17.0",
29-
"typescript": "^4.2.3"
28+
"@typescript-eslint/parser": "^5.31.0",
29+
"typescript": "^4.7.4"
3030
},
3131
"devDependencies": {
3232
"common-tags": "^1.8.0",
33-
"re-reselect": "^4.0.0",
34-
"reselect": "^4.0.0",
33+
"re-reselect": "^4.0.1",
34+
"reselect": "^4.1.6",
3535
"reselect-utils": "^2.0.0-beta.16"
3636
}
3737
}

packages/eslint-plugin-reselect-utils/src/rules/noDifferentProps.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export const noDifferentPropsRule = ruleCreator({
3131
] as [Options],
3232
meta: {
3333
docs: {
34-
category: 'Possible Errors',
3534
description: 'Cached selector and key selector must have same props.',
3635
recommended: 'error',
3736
},

packages/eslint-plugin-reselect-utils/src/rules/requireKeySelector.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const requireKeySelectorRule = ruleCreator({
1919
defaultOptions: [],
2020
meta: {
2121
docs: {
22-
category: 'Possible Errors',
2322
description: 'Cached selector can`t work without key selector.',
2423
recommended: 'error',
2524
},

packages/eslint-plugin-reselect-utils/src/utils/getSelectorProps.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
import ts from 'typescript';
22

3+
export function getTypeArguments(
4+
type: ts.TypeReference,
5+
checker: ts.TypeChecker,
6+
): readonly ts.Type[] {
7+
// getTypeArguments was only added in TS3.7
8+
if (checker.getTypeArguments) {
9+
return checker.getTypeArguments(type);
10+
}
11+
12+
return type.typeArguments ?? [];
13+
}
14+
315
export const getSelectorProps = (
416
selectorType: ts.Type,
517
typeChecker: ts.TypeChecker,
@@ -12,15 +24,17 @@ export const getSelectorProps = (
1224
return [];
1325
}
1426

15-
const [, props] = signature.parameters;
27+
const [, props] = signature.getParameters();
1628
if (props === undefined || props.valueDeclaration === undefined) {
1729
return [];
1830
}
1931

20-
const propsType = typeChecker.getTypeOfSymbolAtLocation(
32+
const nodeType = typeChecker.getTypeOfSymbolAtLocation(
2133
props,
2234
props.valueDeclaration,
2335
);
2436

25-
return typeChecker.getPropertiesOfType(propsType);
37+
const [params] = getTypeArguments(nodeType as ts.TypeReference, typeChecker);
38+
39+
return typeChecker.getPropertiesOfType(params ?? nodeType);
2640
};

packages/reselect-utils/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
"@types/react": "^17.0.0",
3131
"cytoscape": "^3.17.1",
3232
"cytoscape-dagre": "^2.3.2",
33-
"re-reselect": "^4.0.0",
33+
"re-reselect": "^4.0.1",
3434
"react": "^16.13.1",
35-
"reselect": "^4.0.0",
35+
"reselect": "^4.1.6",
3636
"reselect-tools": "^0.0.7"
3737
}
3838
}

packages/reselect-utils/src/__tests__/createChainSelector.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ describe('createChainSelector', () => {
8484
);
8585

8686
(fullNameNamedSelector as NamedParametricSelector<
87+
unknown,
8788
unknown,
8889
unknown,
8990
unknown

packages/reselect-utils/src/createCachedSequenceSelector.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { Options, ParametricOptions } from './types';
44
import { createSequenceSelector } from './createSequenceSelector';
55

66
export function createCachedSequenceSelector<S, R>(
7-
selectors: Selector<S, R>[],
7+
selectors: Selector<S, R, never>[],
88
): (
9-
options: Options<S, (...results: R[]) => R[], Selector<S, R>[]>,
10-
) => Selector<S, R[]>;
9+
options: Options<S, (...results: R[]) => R[], Selector<S, R, never>[]>,
10+
) => Selector<S, R[], never>;
1111

1212
export function createCachedSequenceSelector<S, P, R>(
1313
selectors: ParametricSelector<S, P, R>[],

packages/reselect-utils/src/createCachedStructuredSelector.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import { createStructuredSelector } from './createStructuredSelector';
55

66
export function createCachedStructuredSelector<M>(
77
selectors: M,
8-
): M extends { [K in keyof M]: Selector<infer S, unknown> }
8+
): M extends { [K in keyof M]: Selector<infer S, unknown, never> }
99
? (
1010
options: Options<
1111
S,
1212
(...results: unknown[]) => { [K in keyof M]: ReturnType<M[K]> },
13-
Selector<S, unknown>[]
13+
Selector<S, unknown, never>[]
1414
>,
15-
) => Selector<S, { [K in keyof M]: ReturnType<M[K]> }>
15+
) => Selector<S, { [K in keyof M]: ReturnType<M[K]> }, never>
1616
: M extends { [K in keyof M]: ParametricSelector<infer S, infer P, unknown> }
1717
? (
1818
options: ParametricOptions<

packages/reselect-utils/src/createChainSelector.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export type ChainSelectorOptions = {
4545
};
4646

4747
export type SelectorChain<R1, S, P, R2> =
48-
| ((result: R1) => Selector<S, R2>)
48+
| ((result: R1) => Selector<S, R2, never>)
4949
| ((result: R1) => ParametricSelector<S, P, R2>);
5050

5151
export type SelectorChainHierarchy<
@@ -54,15 +54,15 @@ export type SelectorChainHierarchy<
5454
> = C & { parentChain?: H };
5555

5656
export type SelectorCreator<S, P, R1, R2> = (
57-
selector: Selector<S, R1> | ParametricSelector<S, P, R1>,
57+
selector: Selector<S, R1, never> | ParametricSelector<S, P, R1>,
5858
combiner: (result: R1) => R2,
59-
) => Selector<S, R2> | ParametricSelector<S, P, R2>;
59+
) => Selector<S, R2, never> | ParametricSelector<S, P, R2>;
6060

6161
export class SelectorMonad<
6262
S1,
6363
P1,
6464
R1,
65-
SelectorType extends Selector<S1, R1> | ParametricSelector<S1, P1, R1>,
65+
SelectorType extends Selector<S1, R1, never> | ParametricSelector<S1, P1, R1>,
6666
SelectorChainType extends SelectorChainHierarchy<any, any>
6767
> {
6868
private readonly selector: SelectorType;
@@ -82,16 +82,16 @@ export class SelectorMonad<
8282
}
8383

8484
public chain<S2, R2>(
85-
fn: (result: R1) => Selector<S2, R2>,
85+
fn: (result: R1) => Selector<S2, R2, never>,
8686
options?: ChainSelectorOptions,
87-
): SelectorType extends Selector<S1, R1>
87+
): SelectorType extends Selector<S1, R1, never>
8888
? SelectorMonad<
8989
S1 & S2,
9090
void,
9191
R2,
9292
NamedSelector<S1 & S2, R2>,
9393
SelectorChainHierarchy<
94-
(result: R1) => Selector<S2, R2>,
94+
(result: R1) => Selector<S2, R2, never>,
9595
SelectorChainType
9696
>
9797
>
@@ -101,15 +101,15 @@ export class SelectorMonad<
101101
R2,
102102
NamedParametricSelector<S1 & S2, P1, R2>,
103103
SelectorChainHierarchy<
104-
(result: R1) => Selector<S2, R2>,
104+
(result: R1) => Selector<S2, R2, never>,
105105
SelectorChainType
106106
>
107107
>;
108108

109109
public chain<S2, P2, R2>(
110110
fn: (result: R1) => ParametricSelector<S2, P2, R2>,
111111
options?: ChainSelectorOptions,
112-
): SelectorType extends Selector<S1, R1>
112+
): SelectorType extends Selector<S1, R1, never>
113113
? SelectorMonad<
114114
S1 & S2,
115115
P2,
@@ -276,17 +276,17 @@ export class SelectorMonad<
276276
}
277277

278278
export function createChainSelector<S, R>(
279-
selector: Selector<S, R>,
279+
selector: Selector<S, R, never>,
280280
options?: ChainSelectorOptions,
281-
): SelectorMonad<S, void, R, Selector<S, R>, void>;
281+
): SelectorMonad<S, void, R, Selector<S, R, never>, void>;
282282

283283
export function createChainSelector<S, P, R>(
284284
selector: ParametricSelector<S, P, R>,
285285
options?: ChainSelectorOptions,
286286
): SelectorMonad<S, P, R, ParametricSelector<S, P, R>, void>;
287287

288288
export function createChainSelector<S, P, R>(
289-
selector: Selector<S, R> | ParametricSelector<S, P, R>,
289+
selector: Selector<S, R, never> | ParametricSelector<S, P, R>,
290290
options?: ChainSelectorOptions,
291291
) {
292292
return new SelectorMonad<S, P, R, typeof selector, never>(

0 commit comments

Comments
 (0)