Skip to content

Commit d81c0b4

Browse files
committed
Fixed 20.7
1 parent e2ab313 commit d81c0b4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/04-generics-advanced/20.7-working-around-partial-inference.problem.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Equal, Expect } from "../helpers/type-utils";
22

33
export const makeSelectors = <
44
TSource,
5-
TSelectors extends Record<string, (source: TSource) => any> = {},
5+
TSelectors extends Record<string, (source: TSource) => any>,
66
>(
77
selectors: TSelectors,
88
) => {
@@ -35,11 +35,11 @@ const selectors = makeSelectors<Source>({
3535
});
3636

3737
type tests = [
38-
Expect<Equal<typeof selectors["getFullName"], (source: Source) => string>>,
38+
Expect<Equal<(typeof selectors)["getFullName"], (source: Source) => string>>,
3939
Expect<
40-
Equal<typeof selectors["getFirstAndLastName"], (source: Source) => string>
40+
Equal<(typeof selectors)["getFirstAndLastName"], (source: Source) => string>
4141
>,
4242
Expect<
43-
Equal<typeof selectors["getFirstNameLength"], (source: Source) => number>
43+
Equal<(typeof selectors)["getFirstNameLength"], (source: Source) => number>
4444
>,
4545
];

src/04-generics-advanced/20.7-working-around-partial-inference.solution.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Equal, Expect } from "../helpers/type-utils";
33
export const makeSelectors =
44
<TSource = "makeSelectors expects to be passed a type argument">() =>
55
<TSelectors extends Record<string, (source: TSource) => any>>(
6-
selectors: TSelectors
6+
selectors: TSelectors,
77
) => {
88
return selectors;
99
};
@@ -22,11 +22,11 @@ const selectors = makeSelectors<Source>()({
2222
});
2323

2424
type tests = [
25-
Expect<Equal<typeof selectors["getFullName"], (source: Source) => string>>,
25+
Expect<Equal<(typeof selectors)["getFullName"], (source: Source) => string>>,
2626
Expect<
27-
Equal<typeof selectors["getFirstAndLastName"], (source: Source) => string>
27+
Equal<(typeof selectors)["getFirstAndLastName"], (source: Source) => string>
2828
>,
2929
Expect<
30-
Equal<typeof selectors["getFirstNameLength"], (source: Source) => number>
31-
>
30+
Equal<(typeof selectors)["getFirstNameLength"], (source: Source) => number>
31+
>,
3232
];

0 commit comments

Comments
 (0)