Custom Types
Type Definitions
// Example: define a record type called User, then define
// a function which accepts a User as its argument.
type User = {
name: text,
email: text,
gropIds: number*
};
function getEmail(user: User) => user.email;
let u = new User {
name: "Florian",
email: "[email protected]",
gropIds: [1, 2]
};
return getEmail(u);Advanced: Generic type definitions
Last updated
Was this helpful?