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

Type Checking in Javascript with Flow

Type Checking in Javascript with Flow

Developers like coding in JavaScript because it helps them move fast. The language facilitates fast prototyping of ideas via dynamic typing. However, evolving and growing a JavaScript codebase is notoriously challenging. Developers cannot move fast when they break stuff. Flow is a project that adds a layer of types to a JavaScript codebase, and provide tools that use type information to solve the above problems.

Yos Riady

April 02, 2018
Tweet

More Decks by Yos Riady

Other Decks in Programming

Transcript

  1. Weak types in JS What is Flow? Introduction Flow Types

    Tools Conclusion Working with Flow Summary and further learning Tooling for Flow
  2. Type Annotations Specify your intentions as type annotations in code,

    and Flow will check that everything is behaving as expected.
  3. Weak types in JS What is Flow? Introduction Flow Types

    Tools Conclusion Working with Flow Summary and further learning Tooling for Flow
  4. Function Types Functions have two places where types are applied:

    Parameters (input) and the return value (output).
  5. Maybe Types Maybe types are for places where a value

    is optional and you can create them by adding a question mark in front of the type such as ?string or ?number.
  6. Optional Parameters / Properties Functions / objects can have optional

    parameters / properties where a question mark ? comes after the parameter name.
  7. Reusable Types with Type Aliases When you have complicated types

    that you want to reuse in multiple places, you can alias them in Flow using a type alias.
  8. Weak types in JS What is Flow? Introduction Flow Types

    Tools Conclusion Working with Flow Summary and further learning Tooling for Flow
  9. Flow Tooling Linter Compiler You’ll need to setup a compiler

    to strip away Flow types from your final code. Install Flow per project to perform type checking on your JS files.
  10. Weak types in JS What is Flow? Introduction Flow Types

    Tools Conclusion Working with Flow Summary and further learning Tooling for Flow
  11. Q&A