Custom Types
Type Definitions
FlowScript is a structurally typed language, but it is possible to create named types. Using a named type allows you to deserialize JSON, or write groups of functions operating on the same type of data without a lot of repetition.
Note that all values in this program are still structurally typed. In other words, the following permutation is perfectly valid:
In other words, the getEmail function accepts all records which have at least the members defined in the User type. There is no requirement that they be created using the new User construct, and they are allowed to have additional members not listed in the type. (For in-depth information, refer to the appendix on subtyping rules.)
Advanced: Generic type definitions
Like functions, types can be generic. Type variables are written in angle brackets after the type name.
Last updated