typescriptable me

Why Typescript?

  • You'll code faster
    • You'll catch type errors before they become errors
    • Code's easier to read.
  • Your team will work better together
    • Every function will *tell* you what it expects and what you get back. 

How Typescript?

  1. Set up Typescript in your workflow - it takes the place of Babel
  2. .js and .jsx files work normally and interoperate completely - to use typescript in a specific file, use .ts and .tsx, which will transpile to .js files. 
  3. Write types as you go - if you get stuck, use "any".  

Things that trip up new-to-TS developers working on a TS project * The value of TS is that it encourages you to think about the structure of your object, and in turn, write simpler, cleaner, flatter, more functional code... and if you are inheriting a project that is complex to begin with and then try to transfer over to TS, types can be really nasty. * JSX can really do a number on Typescript as React has very specific types and each component is essentially a massive higher-order-component with about 20 levels of currying, as each child is passed as part of a parameter to the parent function, and is a function itself with it's own children. * Some libraries still don't support typescript well and aren't designed to be used in a way that is easy to test and easy to type (like Styled-Components)

Typescript

By brianboyko

Typescript

  • 389