December 2018
Intermediate to advanced
642 pages
15h 5m
English
In Flow (and TypeScript as well), types that are structurally the same are considered to be compatible and one can be used instead of the other. Let's consider an example. In Uruguay, there is a national identification card with a DNI code: this is a string that's formed by seven digits, a dash, and a check digit. You could have an application that lets you update people's data:
// Source file: src/opaque_types.jstype dniType = string;type nameType = string;function updateClient(id: number, dni: dniType, name: nameType) { /* Talk to some server Update the DNI and name for the client with given id */}
What could happen? If you don't define better types, there's nothing preventing you from doing a call such as ...
Read now
Unlock full access