Created
November 8, 2017 16:38
-
-
Save steida/d4c6da4d108e748af2c823231e0f0eca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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