Skip to content

Commit 9176bdc

Browse files
committed
Finished 27
1 parent 4093869 commit 9176bdc

6 files changed

+57
-8
lines changed

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@types/node": "^18.6.5",
99
"chokidar": "^3.5.3",
1010
"cross-fetch": "^3.1.5",
11+
"prettier": "^2.8.7",
1112
"typescript": "^5.0.2",
1213
"vitest": "^0.21.1"
1314
},
@@ -100,4 +101,4 @@
100101
"ts-toolbelt": "^9.6.0",
101102
"zod": "^3.19.1"
102103
}
103-
}
104+
}

src/06-identity-functions/27-const-annotations.solution.ts renamed to src/06-identity-functions/27-const-annotations.solution.1.ts

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

33
export const asConst = <const T>(t: T) => t;
44

5-
/**
6-
* Now, fruits is typed as:
7-
* [{ name: "apple"; price: 1 }, { name: "banana"; price: 2 }]
8-
*
9-
* Try changing the argument to asConst to see how it affects
10-
* the type.
11-
*/
125
const fruits = asConst([
136
{
147
name: "apple",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Equal, Expect } from "../helpers/type-utils";
2+
import { F } from "ts-toolbelt";
3+
4+
export const asConst = <T>(t: F.Narrow<T>) => t;
5+
6+
const fruits = asConst([
7+
{
8+
name: "apple",
9+
price: 1,
10+
},
11+
{
12+
name: "banana",
13+
price: 2,
14+
},
15+
]);
16+
17+
type tests = [
18+
Expect<
19+
Equal<
20+
typeof fruits,
21+
[
22+
{
23+
name: "apple";
24+
price: 1;
25+
},
26+
{
27+
name: "banana";
28+
price: 2;
29+
}
30+
]
31+
>
32+
>
33+
];

0 commit comments

Comments
 (0)