Skip to content

Commit 47141d2

Browse files
committed
Updated <Exercise tags
1 parent b4e5ce4 commit 47141d2

12 files changed

+97
-370
lines changed

book-content/chapters/02-ide-superpowers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ acceptsObj({
6969

7070
Practice using the autocomplete shortcut to fill in the object when calling `acceptsObj`.
7171

72-
<Exercise title="Exercise 1: Autocomplete" filePath="/src/016.5-ide-superpowers/044-manually-triggering-autocomplete.problem.ts" />
72+
<Exercise title="Exercise 1: Autocomplete" filePath="/src/016.5-ide-superpowers/044-manually-triggering-autocomplete.problem.ts"></Exercise>
7373

7474
#### Solution 1: Autocomplete
7575

@@ -282,7 +282,7 @@ let element = document.getElementById(12);
282282

283283
How can hovering help to determine what argument `document.getElementById` actually requires? And for a bonus point, what type is `element`?
284284

285-
<Exercise title="Exercise 1: Hovering a Function Call" filePath="/src/016.5-ide-superpowers/041-hovering-a-function-call.problem.ts" />
285+
<Exercise title="Exercise 1: Hovering a Function Call" filePath="/src/016.5-ide-superpowers/041-hovering-a-function-call.problem.ts"></Exercise>
286286

287287
#### Solution 1: Hovering a Function Call
288288

@@ -363,7 +363,7 @@ In order to understand what this function does, you'd have to read the code.
363363

364364
Add some documentation to the function so that when you hover over it, you can read a description of what it does.
365365

366-
<Exercise title="Exercise 1: Adding Documentation For Hovers" filePath="/src/016.5-ide-superpowers/042-adding-tsdoc-comments-for-hovers.problem.ts" />
366+
<Exercise title="Exercise 1: Adding Documentation For Hovers" filePath="/src/016.5-ide-superpowers/042-adding-tsdoc-comments-for-hovers.problem.ts"></Exercise>
367367

368368
#### Solution 1: Adding Documentation for Hovers
369369

@@ -512,7 +512,7 @@ Highlight a variable, line, or entire code block then hit `Command + .` to open
512512

513513
Experiment with different options to see how they affect the example function.
514514

515-
<Exercise title="Exercise 1: Quick Fix Refactoring" filePath="/src/016.5-ide-superpowers/050-refactor.problem.ts" />
515+
<Exercise title="Exercise 1: Quick Fix Refactoring" filePath="/src/016.5-ide-superpowers/050-refactor.problem.ts"></Exercise>
516516

517517
### Solution 1: Quick Fix Refactoring
518518

book-content/chapters/04-essential-types-and-annotations.md

Lines changed: 22 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,7 @@ Finally, we can see that our `test` result has an error because the `result` is
283283

284284
Your challenge is to consider how we can change the types to make the errors go away, and to ensure that `result` is a `number`. You can hover over `result` to check it.
285285

286-
<Exercise
287-
title="Exercise 1: Basic Types with Function Parameters"
288-
filePath="/src/015-essential-types-and-annotations/020-basic-types-with-function-parameters.problem.ts"
289-
/>
286+
<Exercise title="Exercise 1: Basic Types with Function Parameters" filePath="/src/015-essential-types-and-annotations/020-basic-types-with-function-parameters.problem.ts"></Exercise>
290287

291288
#### Exercise 2: Annotating Empty Parameters
292289

@@ -320,10 +317,7 @@ type test = Expect<Equal<typeof result, string>>;
320317

321318
Your job is to add some function paramater annotations to the `concatTwoStrings` function to make the errors go away.
322319

323-
<Exercise
324-
title="Exercise 2: Annotating Empty Parameters"
325-
filePath="/src/015-essential-types-and-annotations/021-annotating-empty-parameters.problem.ts"
326-
/>
320+
<Exercise title="Exercise 2: Annotating Empty Parameters" filePath="/src/015-essential-types-and-annotations/021-annotating-empty-parameters.problem.ts"></Exercise>
327321

328322
#### Exercise 3: The Basic Types
329323

@@ -360,10 +354,7 @@ Type 'boolean' is not assignable to type 'string'.
360354

361355
Change the types of the annotations on each variable to make the errors go away.
362356

363-
<Exercise
364-
title="Exercise 3: The Basic Types"
365-
filePath="/src/015-essential-types-and-annotations/022-all-types.problem.ts"
366-
/>
357+
<Exercise title="Exercise 3: The Basic Types" filePath="/src/015-essential-types-and-annotations/022-all-types.problem.ts"></Exercise>
367358

368359
#### Exercise 4: The `any` Type
369360

@@ -388,7 +379,7 @@ it("Should handle a form submit", () => {
388379
const form = document.createElement("form");
389380

390381
form.innerHTML = `
391-
<input name="name" value="John Doe" />
382+
<input name="name" value="John Doe"></Exercise>
392383
`;
393384

394385
form.onsubmit = (e) => {
@@ -423,10 +414,7 @@ Why is this error happening? Why isn't TypeScript giving us an error here?
423414

424415
I'll give you a clue. I've hidden a nasty typo in there. Can you fix it?
425416

426-
<Exercise
427-
title="Exercise 4: The `any` Type"
428-
filePath="/src/015-essential-types-and-annotations/032.5-any.problem.ts"
429-
/>
417+
<Exercise title="Exercise 4: The `any` Type" filePath="/src/015-essential-types-and-annotations/032.5-any.problem.ts"></Exercise>
430418

431419
#### Solution 1: Basic Types with Function Parameters
432420

@@ -616,10 +604,7 @@ We can tell from the `concatName` function body that it expects `user.first` and
616604

617605
How could we type the `user` parameter to ensure that it has these properties and that they are of the correct type?
618606

619-
<Exercise
620-
title="Exercise 1: Object Literal Types"
621-
filePath="/src/015-essential-types-and-annotations/025-object-literal-types.problem.ts"
622-
/>
607+
<Exercise title="Exercise 1: Object Literal Types" filePath="/src/015-essential-types-and-annotations/025-object-literal-types.problem.ts"></Exercise>
623608

624609
#### Exercise 2: Optional Property Types
625610

@@ -668,10 +653,7 @@ The error tells us that we are missing a property, but the error is incorrect. W
668653

669654
How would you update this function to fix the errors?
670655

671-
<Exercise
672-
title="Exercise 2: Optional Property Types"
673-
filePath="/src/015-essential-types-and-annotations/026-optional-property-types.problem.ts"
674-
/>
656+
<Exercise title="Exercise 2: Optional Property Types" filePath="/src/015-essential-types-and-annotations/026-optional-property-types.problem.ts"></Exercise>
675657

676658
#### Solution 1: Object Literal Types
677659

@@ -857,10 +839,7 @@ Even though everything is working as expected, there's an opportunity for refact
857839

858840
How could you use the `type` keyword to make this code more readable?
859841

860-
<Exercise
861-
title="Exercise 1: The `type` Keyword"
862-
filePath="/src/015-essential-types-and-annotations/027-type-keyword.problem.ts"
863-
/>
842+
<Exercise title="Exercise 1: The `type` Keyword" filePath="/src/015-essential-types-and-annotations/027-type-keyword.problem.ts"></Exercise>
864843

865844
#### Solution 1: The `type` Keyword
866845

@@ -1072,10 +1051,7 @@ As the error message points out, there is not currently a property called `items
10721051

10731052
How would you fix this error?
10741053

1075-
<Exercise
1076-
title="Exercise 1: Array Type"
1077-
filePath="/src/015-essential-types-and-annotations/028-arrays.problem.ts"
1078-
/>
1054+
<Exercise title="Exercise 1: Array Type" filePath="/src/015-essential-types-and-annotations/028-arrays.problem.ts"></Exercise>
10791055

10801056
#### Exercise 2: Arrays of Objects
10811057

@@ -1112,10 +1088,7 @@ Object literal may only specify known properties, and 'ingredients' does not exi
11121088

11131089
By combining what you've seen with typing object properties and working with arrays, how would you specify ingredients for the `Recipe` type?
11141090

1115-
<Exercise
1116-
title="Exercise 2: Arrays of Objects"
1117-
filePath="/src/015-essential-types-and-annotations/029-arrays-of-objects.problem.ts"
1118-
/>
1091+
<Exercise title="Exercise 2: Arrays of Objects" filePath="/src/015-essential-types-and-annotations/029-arrays-of-objects.problem.ts"></Exercise>
11191092

11201093
#### Exercise 3: Tuples
11211094

@@ -1170,10 +1143,7 @@ setRange([0, 10, 20]);
11701143

11711144
The code for the `setRange` function needs an updated type annotation to specify that it only accepts a tuple of two numbers.
11721145

1173-
<Exercise
1174-
title="Exercise 3: Tuples"
1175-
filePath="/src/015-essential-types-and-annotations/031-tuples.problem.ts"
1176-
/>
1146+
<Exercise title="Exercise 3: Tuples" filePath="/src/015-essential-types-and-annotations/031-tuples.problem.ts"></Exercise>
11771147

11781148
#### Exercise 4: Optional Members of Tuples
11791149

@@ -1201,10 +1171,7 @@ const goToLocation = (coordinates: Array<number>) => {
12011171

12021172
Your challenge is to update the type annotation for the `coordinates` parameter to specify that it should be a tuple of three numbers, where the third number is optional.
12031173

1204-
<Exercise
1205-
title="Exercise 4: Optional Members of Tuples"
1206-
filePath="/src/015-essential-types-and-annotations/032-optional-members-of-tuples.problem.ts"
1207-
/>
1174+
<Exercise title="Exercise 4: Optional Members of Tuples" filePath="/src/015-essential-types-and-annotations/032-optional-members-of-tuples.problem.ts"></Exercise>
12081175

12091176
#### Solution 1: Array Type
12101177

@@ -1486,10 +1453,7 @@ new () => Map<any, any> (+3 overloads)
14861453

14871454
How would we type the `userMap` so the key must be a number and the value is an object with `name` and `age` properties?
14881455

1489-
<Exercise
1490-
title="Exercise 1: Passing Types to Map"
1491-
filePath="/src/015-essential-types-and-annotations/036-pass-types-to-map.problem.ts"
1492-
/>
1456+
<Exercise title="Exercise 1: Passing Types to Map" filePath="/src/015-essential-types-and-annotations/036-pass-types-to-map.problem.ts"></Exercise>
14931457

14941458
#### Exercise 2: `JSON.parse()` Can't Receive Type Arguments
14951459

@@ -1543,10 +1507,7 @@ The test errors tell us that the type of `parsed` is not what we expect. The pro
15431507

15441508
Why this is happening? What would be an different way to correct these type errors?
15451509

1546-
<Exercise
1547-
title="Exercise 2: `JSON.parse()` Can't Receive Type Arguments"
1548-
filePath="/src/015-essential-types-and-annotations/037-json-parse-cant-receive-type-arguments.problem.ts"
1549-
/>
1510+
<Exercise title="Exercise 2: `JSON.parse()` Can't Receive Type Arguments" filePath="/src/015-essential-types-and-annotations/037-json-parse-cant-receive-type-arguments.problem.ts"></Exercise>
15501511

15511512
#### Solution 1: Passing Types to Map
15521513

@@ -1911,10 +1872,7 @@ const result2 = concatName("John");
19111872

19121873
Try to use an optional parameter annotation to fix the error.
19131874

1914-
<Exercise
1915-
title="Exercise 1: Optional Function Parameters"
1916-
filePath="/src/015-essential-types-and-annotations/023-optional-function-parameters.problem.ts"
1917-
/>
1875+
<Exercise title="Exercise 1: Optional Function Parameters" filePath="/src/015-essential-types-and-annotations/023-optional-function-parameters.problem.ts"></Exercise>
19181876

19191877
#### Exercise 2: Default Function Parameters
19201878

@@ -1972,10 +1930,7 @@ expect(result).toEqual("John Pocock");
19721930

19731931
Update the `concatName` function to use `Pocock` as the default last name if one is not provided.
19741932

1975-
<Exercise
1976-
title="Exercise 2: Default Function Parameters"
1977-
filePath="/src/015-essential-types-and-annotations/024-default-function-parameters.problem.ts"
1978-
/>
1933+
<Exercise title="Exercise 2: Default Function Parameters" filePath="/src/015-essential-types-and-annotations/024-default-function-parameters.problem.ts"></Exercise>
19791934

19801935
#### Exercise 3: Rest Parameters
19811936

@@ -2004,10 +1959,7 @@ The test passes, but there's an error on the `...strings` rest parameter.
20041959

20051960
How would you update the rest parameter to specify that it should be an array of strings?
20061961

2007-
<Exercise
2008-
title="Exercise 3: Rest Parameters"
2009-
filePath="/src/015-essential-types-and-annotations/030-rest-parameters.problem.ts"
2010-
/>
1962+
<Exercise title="Exercise 3: Rest Parameters" filePath="/src/015-essential-types-and-annotations/030-rest-parameters.problem.ts"></Exercise>
20111963

20121964
#### Exercise 4: Function Types
20131965

@@ -2081,10 +2033,7 @@ modifyUser(
20812033

20822034
How would you type `makeChange` as a function takes in a `User` and returns a `User`?
20832035

2084-
<Exercise
2085-
title="Exercise 4: Function Types"
2086-
filePath="/src/015-essential-types-and-annotations/033-function-types.problem.ts"
2087-
/>
2036+
<Exercise title="Exercise 4: Function Types" filePath="/src/015-essential-types-and-annotations/033-function-types.problem.ts"></Exercise>
20882037

20892038
#### Exercise 5: Functions Returning `void`
20902039

@@ -2125,10 +2074,7 @@ This is triggering our `@ts-expect-error` directive.
21252074

21262075
How should `addClickEventListener` be typed so that each error is resolved?
21272076

2128-
<Exercise
2129-
title="Exercise 5: Functions Returning `void`"
2130-
filePath="/src/015-essential-types-and-annotations/034-functions-returning-void.problem.ts"
2131-
/>
2077+
<Exercise title="Exercise 5: Functions Returning `void`" filePath="/src/015-essential-types-and-annotations/034-functions-returning-void.problem.ts"></Exercise>
21322078

21332079
#### Exercise 6: `void` vs `undefined`
21342080

@@ -2158,10 +2104,7 @@ acceptsCallback(returnString);
21582104

21592105
Why is this happening? Can we alter the type of `acceptsCallback` to fix this error?
21602106

2161-
<Exercise
2162-
title="Exercise 6: `void` vs `undefined`"
2163-
filePath="/src/015-essential-types-and-annotations/034.5-void-vs-undefined.problem.ts"
2164-
/>
2107+
<Exercise title="Exercise 6: `void` vs `undefined`" filePath="/src/015-essential-types-and-annotations/034.5-void-vs-undefined.problem.ts"></Exercise>
21652108

21662109
#### Exercise 7: Typing Async Functions
21672110

@@ -2232,10 +2175,7 @@ How can we type `data` as a number without changing the calls to `fetch` or `res
22322175

22332176
There are two possible solutions here.
22342177

2235-
<Exercise
2236-
title="Exercise 7: Typing Async Functions"
2237-
filePath="/src/015-essential-types-and-annotations/038-type-async-functions.problem.ts"
2238-
/>
2178+
<Exercise title="Exercise 7: Typing Async Functions" filePath="/src/015-essential-types-and-annotations/038-type-async-functions.problem.ts"></Exercise>
22392179

22402180
#### Solution 1: Optional Function Parameters
22412181

@@ -2441,7 +2381,7 @@ This works because `data` was `any` before, and `await response.json()` returns
24412381

24422382
However, the best way to solve this problem is to add a return type to the function. In this case, it should be a `number`:
24432383

2444-
```ts
2384+
```ts twoslash
24452385
// @errors: 1064
24462386
async function fetchData(): number {
24472387
// function body

0 commit comments

Comments
 (0)