Skip to content

Commit

Permalink
Fixed error in the weird parts
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Jul 17, 2024
1 parent 399c25f commit 6b2cc39
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions book-content/chapters/12-the-weird-parts.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,16 @@ This can make you _think_ that TypeScript cares about excess properties - but it
This behavior can be frustrating when you misspell the names of an optional parameter. Imagine you misspell `timeout` as `timeOut`:

```typescript
const fetch = (options: { timeout?: number }) => {
const myFetch = (options: { url: string; timeout?: number }) => {
// Implementation
};

const options = {
url: "/",
timeOut: 1000,
};

fetch(options); // No error!
myFetch(options); // No error!
```

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:
Expand Down

0 comments on commit 6b2cc39

Please sign in to comment.