Using Derivable with FlowType

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.

Like what you read? Give Andrey Popp a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.