Skip to content

Possible Typos #59

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion book-content/chapters/05-unions-literals-and-narrowing.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ We could then specify `AlbumFormat` as a union of `DigitalFormat` and `PhysicalF
type AlbumFormat = DigitalFormat | PhysicalFormat;
```

Now, we can use the `DigitalFormat` type for functions that handle digital formats, and the `AnalogFormat` type for functions that handle analog formats. The `AlbumFormat` type can be used for functions that handle all cases.
Now, we can use the `DigitalFormat` type for functions that handle digital formats, and the `PhysicalFormat` type for functions that handle physical formats. The `AlbumFormat` type can be used for functions that handle all cases.

This way, we can ensure that each function only handles the cases it's supposed to handle, and TypeScript will throw an error if we try to pass an incorrect format to a function.

Expand Down
8 changes: 4 additions & 4 deletions book-content/chapters/09-typescript-only-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,18 +371,18 @@ namespace RecordStoreUtils {
}
```

In this example, `AlbumCollection` is the main namespace, with `Sales` as a nested namespace. This structure helps in organizing the code by functionality and makes it clear which part of the application each function pertains to.
In this example, `RecordStoreUtils` is the main namespace, with `Sales` as a nested namespace. This structure helps in organizing the code by functionality and makes it clear which part of the application each function pertains to.

The stuff inside of the `AlbumCollection` can be used as values or types:
The stuff inside of the `RecordStoreUtils` can be used as values or types:

```typescript
const odelay: AlbumCollection.Album.Album = {
const odelay: RecordStoreUtils.Album.Album = {
title: "Odelay!",
artist: "Beck",
year: 1996,
};

AlbumCollection.Sales.recordSale("Odelay!", 1, 10.99);
RecordStoreUtils.Sales.recordSale("Odelay!", 1, 10.99);
```

### How Namespaces Compile
Expand Down
1 change: 1 addition & 0 deletions book-content/chapters/14-configuring-typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ To start, here's a recommended base `tsconfig.json` configuration with options a
"isolatedModules": true,
"strict": true,
"noUncheckedIndexedAccess": true
}
}
```

Expand Down
9 changes: 6 additions & 3 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,8 +550,9 @@ 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;
Expand Down