Skip to content

Commit 6b2cc39

Browse files
committed
Fixed error in the weird parts
1 parent 399c25f commit 6b2cc39

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

book-content/chapters/12-the-weird-parts.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,16 @@ This can make you _think_ that TypeScript cares about excess properties - but it
113113
This behavior can be frustrating when you misspell the names of an optional parameter. Imagine you misspell `timeout` as `timeOut`:
114114

115115
```typescript
116-
const fetch = (options: { timeout?: number }) => {
116+
const myFetch = (options: { url: string; timeout?: number }) => {
117117
// Implementation
118118
};
119119

120120
const options = {
121+
url: "/",
121122
timeOut: 1000,
122123
};
123124

124-
fetch(options); // No error!
125+
myFetch(options); // No error!
125126
```
126127

127128
In this case, TypeScript won't show an error, and you won't get the runtime behavior you expect. The only way to source the error would be to provide a type annotation for the `options` object:

0 commit comments

Comments
 (0)