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

React with super powers using TypeScript

React with super powers using TypeScript

ReactJS Milano meetup 1.0 slides.
This talk is about writing React apps using TypeScript, highlighting the advantages comparing to a plain JS approach.

Stefano Armenes

April 03, 2018
Tweet

More Decks by Stefano Armenes

Other Decks in Programming

Transcript

  1. Perché? -> Passaggio da un linguaggio compilato e static typed

    a JS ☹ -> Errori a runtime che potrebbero essere evitati -> Scrivere software sforzandosi fin da subito a “dichiarare” il modello dati -> Facilità di lettura da parte di altre persone -> Auto-documentazione del codice
  2. Typescript -> Basic types boolean, number, string, array, tuple, enum,

    any, void, never, null, undefined -> Interfaces, type aliases -> Enums
  3. Typescript -> Basic types boolean, number, string, array, tuple, enum,

    any, void, never, null, undefined -> Interfaces, type aliases -> Enums -> Generics
  4. Typescript -> Basic types boolean, number, string, array, tuple, enum,

    any, void, never, null, undefined -> Union types, nullable types -> Interfaces, type aliases -> Enums -> Generics
  5. Typescript -> Basic types boolean, number, string, array, tuple, enum,

    any, void, never, null, undefined -> Union types, nullable types -> Type inference -> Interfaces, type aliases -> Enums -> Generics
  6. Typescript -> Basic types boolean, number, string, array, tuple, enum,

    any, void, never, null, undefined -> Type guards -> Union types, nullable types -> Type inference -> Interfaces, type aliases -> Enums -> Generics
  7. Typescript -> Basic types boolean, number, string, array, tuple, enum,

    any, void, never, null, undefined -> Type guards -> Union types, nullable types -> Type inference -> Control flow based type analysis -> Interfaces, type aliases -> Enums -> Generics
  8. yarn add -D @types/${lib-name} Typings everywhere Libreria scritta in JS?

    Nessun problema (o quasi) …ma spesso integrati nella libreria stessa
  9. Ok ma… come inizio? https://basarat.gitbooks.io/typescript/ https://egghead.io/courses/use-typescript-to-develop-react-applications https://egghead.io/courses/advanced-static-types-in-typescript yarn global add

    create-react-app create-react-app my-app "--scripts-version=react-scripts-ts cd my-app/ yarn start http://www.typescriptlang.org/docs/home.html