- Flow is great for your own code, but what about 3rd party libraries?
import express from 'express';
const app = express()
app.gettt() # doesn't exist, but flow doesn't know this
- Flow type definition files!
yarn global add flow-typed
yarn add flow-bin --dev
# installs definition files for libraries found in node_modules
flow-typed install
- Now, rerunning flow will return
property `gettt` Property not found in Application
- Now imagine a script that reruns
flow-typed install after every yarn add.
- At 16:40, state machines:
// a "tagged union" to represent a state machine
type State = {
screen: 'loading',
} | {
screen: 'answering',
problems: Array<Problem>,
answers: Array<Answer>,
currentProblem: number,
} | {
screen: 'finished',
pointsData: PointsData,
}
- If you're making a ton of things optional, you're probably trying to represent a state machine poorly.