Skip to content

Commit 00c2550

Browse files
committed
Fixed 28
1 parent 61ad493 commit 00c2550

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/05-function-overloads/28-could-be-instantiated-with-subtype-of.problem.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ const obj = {
88

99
type ObjKey = keyof typeof obj;
1010

11-
const getObjKey = <TKey extends ObjKey>(key: TKey = "a") => {
11+
const getObjValue = <TKey extends ObjKey>(key: TKey = "a") => {
1212
return obj[key];
1313
};
1414

15-
const one = getObjKey("a");
16-
const oneByDefault = getObjKey();
17-
const two = getObjKey("b");
18-
const three = getObjKey("c");
15+
const one = getObjValue("a");
16+
const oneByDefault = getObjValue();
17+
const two = getObjValue("b");
18+
const three = getObjValue("c");
1919

2020
type tests = [
2121
Expect<Equal<typeof one, 1>>,
2222
Expect<Equal<typeof oneByDefault, 1>>,
2323
Expect<Equal<typeof two, 2>>,
24-
Expect<Equal<typeof three, 3>>,
24+
Expect<Equal<typeof three, 3>>
2525
];

src/05-function-overloads/28-could-be-instantiated-with-subtype-of.solution.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ const obj = {
88

99
type ObjKey = keyof typeof obj;
1010

11-
function getObjKey(): 1;
12-
function getObjKey<TKey extends ObjKey>(key: TKey): typeof obj[TKey];
13-
function getObjKey(key: ObjKey = "a") {
11+
function getObjValue(): 1;
12+
function getObjValue<TKey extends ObjKey>(key: TKey): typeof obj[TKey];
13+
function getObjValue(key: ObjKey = "a") {
1414
return obj[key];
1515
}
1616

17-
const one = getObjKey("a");
18-
const oneByDefault = getObjKey();
19-
const two = getObjKey("b");
20-
const three = getObjKey("c");
17+
const one = getObjValue("a");
18+
const oneByDefault = getObjValue();
19+
const two = getObjValue("b");
20+
const three = getObjValue("c");
2121

2222
type tests = [
2323
Expect<Equal<typeof one, 1>>,
2424
Expect<Equal<typeof oneByDefault, 1>>,
2525
Expect<Equal<typeof two, 2>>,
26-
Expect<Equal<typeof three, 3>>,
26+
Expect<Equal<typeof three, 3>>
2727
];

0 commit comments

Comments
 (0)