Using Derivable with FlowType

Andrey Popp
Learn Derivable
Published in
1 min readSep 1, 2016

Derivable ships with FlowType typings out of the box. That means that you can take advantage of type checking your code which uses Derivable — less runtime errors and more confidence and better sleep in the nights.

/** @flow */import type {Atom} from 'derivable'
import {atom} from 'derivable'
let name: Atom<string> = atom('Andrey')name.set(42) // Error: expected a string but got number

As you can see, FlowType already prevented a bug: updating an atom with an invalid value. This is because with stated that name should hold values of type string.

You can take a look at tests for Derivable typings to get an idea of what types of errors FlowType can catch for you before you ship code to production.

--

--