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

This Will Flow Your Mind

Avatar for Tryggvi Gylfason Tryggvi Gylfason
August 24, 2016
42

This Will Flow Your Mind

This talk is about flow, a static type-checker for JavaScript which is developed and maintained by Facebook. We have been using flow extensively at QuizUp for half a year now and it's been a great success in a big JS codebase. In this talk I will answer the following questions:

What is it?
Why use it?
What can it do?
What can't it do?
Lastly I will go over lessons learned and our experience with using flow.

Avatar for Tryggvi Gylfason

Tryggvi Gylfason

August 24, 2016
Tweet

Transcript

  1. 1. WHAT IS IT 2. WHY USE IT 3. WHAT

    CAN IT DO 4. WHAT CAN IT NOT DO 5. LESSONS LEARNED
  2. WHAT IS IT // @flow function addBangToNumber(num: number): string {

    return num + '!' } function addBangToNumber(num /*:number*/) /*:string*/ { return num + '!' }
  3. function enforceObject(x) { if (typeof x === "object") return x

    // x can still be null since `typeof null === "object"` else return {} } WHY USE IT
  4. function enforceObject(x) { if (typeof x === "object" && x

    !== null) return x else return {} } WHY USE IT
  5. function enforceObject(x: ?Object): Object { if (typeof x === "object"

    && x !== null) return x else return {} } WHY USE IT
  6. WHAT CAN IT DO ES6+ async/await Promises Generators Arrow functions

    Destructuring Classes Modules Template strings let/const Spread
  7. WHAT CAN IT NOT DO Warn about additional props not

    declared in a components Props type
  8. IMMUTABLE IMMUTABLE IMMUTABLE Non-native data structures The more things change

    the more they stay immutable “ IMMUTABLE IMMUTABLE IMMUTABLE IMMUTABLE IMMUTABLE “ WHAT CAN IT NOT DO