Skip to content

Commit

Permalink
add link to TS FAQ
Browse files Browse the repository at this point in the history
  • Loading branch information
swyxio committed Jul 23, 2019
1 parent 1a0a5a5 commit 94ca674
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions README.md
Expand Up @@ -988,6 +988,8 @@ _Not written yet._ watch <https://github.com/sw-yx/fresh-async-react> for more o

# Basic Troubleshooting Handbook: Types

> ⚠️ Have you read [the TypeScript FAQ](https://github.com/microsoft/TypeScript/wiki/FAQ)?) Your answer might be there!
Facing weird type errors? You aren't alone. This is the hardest part of using TypeScript with React. Be patient - you are learning a new language after all. However, the more you get good at this, the less time you'll be working _against_ the compiler and the more the compiler will be working _for_ you!

Try to avoid typing with `any` as much as possible to experience the full benefits of typescript. Instead, let's try to be familiar with some of the common strategies to solve these issues.
Expand Down Expand Up @@ -1091,14 +1093,8 @@ A simpler alternative to enum is just declaring a bunch of strings with union:
export declare type Position = "left" | "right" | "top" | "bottom";
```

<details>

<summary>Brief Explanation</summary>

This is handy because TypeScript will throw errors when you mistype a string for your props.

</details>

## Type Assertion

Sometimes you know better than TypeScript that the type you're using is narrower than it thinks, or union types need to be asserted to a more specific type to work with other APIs, so assert with the `as` keyword. This tells the compiler you know better than it does.
Expand Down

0 comments on commit 94ca674

Please sign in to comment.