December 2018
Intermediate to advanced
642 pages
15h 5m
English
Flow supports classes and mostly in an automatic way. Every time you define a class, it becomes a type by itself, so you don't have to do anything else; you can just use it elsewhere. (We'll be seeing more about classes in a short while, in the Working with Objects and Classes section.) You can assign types to properties and methods in the same way as for objects and functions. Using our Person class again as an example, the following code shows how to define it with Flow:
// Source file: src/types_advanced.jsclass Person { // class fields need Flow annotations first: string; last: string; constructor(first: string, last: string) { this.first = first; this.last = last; } initials(): string { return `${this.first[0]}${this.last[0]}`; ...Read now
Unlock full access