Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JavaScriptures 2 - TypeScript

JavaScriptures 2 - TypeScript

Fec952eb14022f55b2747510ac685591?s=128

Artsy Open Source

April 10, 2018
Tweet

Transcript

  1. TypeScript And let it divide the interface from the code

    JavaScriptures II Eloy and Sarah
  2. What even is TypeScript?

  3. Why did we start using TypeScript?

  4. Exercises

  5. Benefits (compared to js)

  6. • It can make stepping into new repos less daunting

    Easier to get acclimated to new repos
  7. • Intellisense in VSCode is slick • [see example] Tooling

  8. • When developing in TS (as opposed to normal JS),

    it’s clear what exactly one expects to happen Keeps code clear
  9. • It’s nice to be able to easily see the

    schema of an application as opposed to maintaining it in your head as you go along Speeds up some parts of the dev process
  10. • When you change something about your schema, you can

    immediately see where breaking changes exist because the type checker will throw errors Allows you to catch errors sooner
  11. Drawbacks

  12. • Currently involves (at least in our case) a complex

    dance between Babel, Webpack, Node, Jest, and possibly more. However, as we move more projects to Babel 7, we can drastically simplify this by utilising its ability to parse TypeScript code. • To debug this sort of thing, one has to look at the docs and github issues of several different projects; there is no singular resource for TS tooling (although our Artsy Engineering blog post on the topic comes close) Setting up tooling can be tedious
  13. • Most JS projects won’t. • Over 4000 community maintained

    type declarations at github.com/DefinitelyTyped/DefinitelyTyped. E.g. @types/react on NPM. • Details on how to write type declarations can be found here: www.typescriptlang.org/docs/handbook/declaration-files/introduction.html Libraries may not come with TS types
  14. • https://www.typescriptlang.org/docs/handbook/basic-types.html • https://github.com/basarat/typescript-book • https://github.com/mike-works/typescript-fundamentals • https://egghead.io/playlists/typescript-with-react-d922273e Helpful Links