Save 37% off PRO during our Black Friday Sale! »

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.

1b0ab2500efc1b91424fb49045312929?s=128

Yos Riady

April 02, 2018
Tweet

Transcript

  1. Type Checking in Javascript with Flow Yos Riady yos.io bit.ly/2Gs04qv

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

    Tools Conclusion Working with Flow Summary and further learning Tooling for Flow
  3. Javascript is weakly typed { userName: “Yos”, favouriteNumber: 42, interests:

    [“programming”, “swimming”] }
  4. None
  5. None
  6. None
  7. Flow is a static type checker for JavaScript.

  8. Type Annotations Specify your intentions as type annotations in code,

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

    Tools Conclusion Working with Flow Summary and further learning Tooling for Flow
  10. Variable Types When you declare a new variable, optionally declare

    its type.
  11. Function Types Functions have two places where types are applied:

    Parameters (input) and the return value (output).
  12. 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.
  13. Optional Parameters / Properties Functions / objects can have optional

    parameters / properties where a question mark ? comes after the parameter name.
  14. Literal Types Flow can also use literal values as types.

  15. Object Types You can annotate the properties of an object

    with types.
  16. 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.
  17. Union Types Sometimes it’s useful to create a type which

    is one of a set of other types.
  18. Interface Types

  19. Importing and Exporting Types You can export type aliases, interfaces,

    and classes from one file to another.
  20. Weak types in JS What is Flow? Introduction Flow Types

    Tools Conclusion Working with Flow Summary and further learning Tooling for Flow
  21. 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.
  22. None
  23. Weak types in JS What is Flow? Introduction Flow Types

    Tools Conclusion Working with Flow Summary and further learning Tooling for Flow
  24. Type Checking in Javascript with Flow Yos Riady yos.io bit.ly/2Gs04qv

  25. Q&A