Skip to content

Instantly share code, notes, and snippets.

@steida
Created November 8, 2017 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steida/d4c6da4d108e748af2c823231e0f0eca to your computer and use it in GitHub Desktop.
Save steida/d4c6da4d108e748af2c823231e0f0eca to your computer and use it in GitHub Desktop.
// Make complex type from primitive types
type Person = {
name: string,
age: number,
}
// Test it.
const joe: Person = {
name: 'Joe',
age: 60,
};
// Generic type.
const persons: Array<Person> = [{ name: 'Joe', age: 60 }]
// Some other type.
type Product = {
name: string,
owner: Person
}
// Test it.
const table: Product = {
name: 'Table 123',
owner: joe
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment