Skip to content

Commit 4fcc8ad

Browse files
committed
Fixed a reference to 'type faith' that never got re-added
1 parent 00674f1 commit 4fcc8ad

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ The reason this works is because `any` disables type checking. So, we can assign
14311431
const parsedData: number = JSON.parse('{"name": "Alice", "age": 30}');
14321432
```
14331433

1434-
So, this is more 'type faith' than 'type safe'. We are hoping that `parsedData` is the type we expect it to be. We'll explore this idea more later in the book.
1434+
So, this is more 'type faith' than 'type safe'. We are hoping that `parsedData` is the type we expect it to be. This relies on us keeping the type annotation up to date with the actual data.
14351435

14361436
## Typing Functions
14371437

@@ -2226,13 +2226,3 @@ async function fetchData(): Promise<number> {
22262226
```
22272227

22282228
By wrapping the `number` inside of `Promise<>`, we make sure that the `data` is awaited before the type is figured out.
2229-
2230-
##### "Type Safe" vs "Type Faith"
2231-
2232-
An interesting note here is that TypeScript is not really enforcing the return type of `fetchData`. It's just assuming that `data` is a `number` because we've told it to be.
2233-
2234-
This is a good example of "type faith" - we're telling TypeScript to trust us that `data` is a `number`. But if it's not, TypeScript won't catch it at runtime.
2235-
2236-
We'll return to this topic later in the book.
2237-
2238-
---

0 commit comments

Comments
 (0)