Skip to content

Commit 60b08e7

Browse files
committed
Improve documentation and fix instruction clarity
- Fix async/await README to say "return" instead of "log" to match tests - Add note about import { type X } syntax for Node.js TypeScript support - Add TypeScript Playground tips for mapped types and conditional types
1 parent ec92731 commit 60b08e7

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

exercises/02.async-await/01.problem.linear-flow/README.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ async/await. This will make the code much more readable!
88
1. Create an `async` function called `loadUserData`
99
2. Use `await` to fetch the user
1010
3. Use `await` to fetch the orders
11-
4. Log both results
11+
4. Return an object with both `user` and `orders`
1212

1313
💰 Async/await syntax:
1414

1515
```ts
1616
async function loadUserData() {
1717
const user = await fetchUser()
1818
const orders = await fetchOrders(user.id)
19-
console.log(user, orders)
19+
return { user, orders }
2020
}
2121
```
2222

exercises/04.modules/01.problem.import-export/README.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@ export type User = { ... }
1717
export type Product = { ... }
1818

1919
// index.ts
20-
import { User, Product } from './types.ts'
20+
import { type User, type Product } from './types.ts'
2121
```
2222

23+
<callout-info>
24+
When importing **types only** (not values), use `import { type X }` syntax.
25+
This tells TypeScript (and Node.js) that these imports are purely for type
26+
checking and should be erased at runtime. This is required when running
27+
TypeScript natively with Node.js.
28+
</callout-info>
29+
2330
📜 [MDN - ES Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
2431

2532
🐨 Once you've completed the exercise, run `node index.ts` in the playground to test your work!

exercises/08.mapped-types/01.problem.creating-mapped-types/README.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ type RemoveOptional<T> = {
2727
2828
📜 [TypeScript Handbook - Mapped Types](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html)
2929
30+
💰 Try experimenting with mapped types in the
31+
[TypeScript Playground](https://www.typescriptlang.org/play) - hover over type
32+
aliases to see how TypeScript evaluates them!
33+
3034
🐨 Once you've completed the exercise, run `node index.ts` in the playground to test your work!

exercises/09.conditional-types/01.problem.basic-conditionals/README.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ type IsArray<T> = T extends any[] ? true : false
2424
2525
📜 [TypeScript Handbook - Conditional Types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html)
2626
27+
💰 Conditional types can be tricky to understand. Try experimenting in the
28+
[TypeScript Playground](https://www.typescriptlang.org/play) - hover over type
29+
aliases to see how TypeScript evaluates each step of the condition!
30+
2731
🐨 Once you've completed the exercise, run `node index.ts` in the playground to test your work!

exercises/09.conditional-types/02.problem.basic-infer/README.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,8 @@ T extends (...args: any[]) => infer R ? R : never
4444

4545
📜 [TypeScript Handbook - Inferring Within Conditional Types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types)
4646

47+
💰 The [TypeScript Playground](https://www.typescriptlang.org/play) is especially
48+
helpful for understanding `infer`. Hover over type aliases to see how TypeScript
49+
infers the captured type variables!
50+
4751
🐨 Once you've completed the exercise, run `node index.ts` in the playground to test your work!

exercises/09.conditional-types/03.problem.infer-keyword/README.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ type LastElement<T> = T extends [...infer _, infer L] ? L : never
4848
4949
📜 [TypeScript Handbook - Inferring Within Conditional Types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types)
5050
51+
💰 Use the [TypeScript Playground](https://www.typescriptlang.org/play) to
52+
experiment with different tuple patterns. Hover over your type aliases to see
53+
how TypeScript evaluates each step!
54+
5155
🐨 Once you've completed the exercise, run `node index.ts` in the playground to test your work!

0 commit comments

Comments
 (0)