Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos in Chapter 16 #51

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions book-content/chapters/16-the-utils-folder.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,9 @@ function assertIsAlbum(input: unknown): asserts input is Album {
"artist" in input &&
"year" in input
) {
throw new Error("Not an Album!");
return;
}
throw new Error("Not an Album!");
}
```

Expand All @@ -522,8 +523,9 @@ function assertIsAlbum(input: unknown): asserts input is Album {
"artist" in input &&
"year" in input
) {
throw new Error("Not an Album!");
return;
}
throw new Error("Not an Album!");
}
// ---cut---
function getAlbumTitle(item: unknown) {
Expand All @@ -548,11 +550,12 @@ For example, if the `assertIsAlbum` function doesn't check for all the required
```typescript
function assertIsAlbum(input: unknown): asserts input is Album {
if (typeof input === "object") {
throw new Error("Not an Album!");
return;
}
throw new Error("Not an Album!");
}

let item = null;
let item: unknown = null;

assertIsAlbum(item);

Expand Down Expand Up @@ -877,7 +880,7 @@ it("Should accept a custom error", () => {

Your task is to update the `addCodeToError` type signature to enforce the required constraints so that `TError` is required to have a `message` property and can optionally have a `code` property.

<Exercise title="Exercise 4: Type Parameter Constraints" filePath="/src/085-the-utils-folder/216-type-parameter-defaults-in-generic-functions.problem.ts"></Exercise>
<Exercise title="Exercise 4: Type Parameter Constraints" filePath="/src/085-the-utils-folder/218-type-parameter-constraints-with-generic-functions.problem"></Exercise>

### Exercise 5: Combining Generic Types and Functions

Expand Down