typescript nested types code example
Example 1: nested array typescript
interface IThing {
active: boolean
}
interface IStuff {
name: string;
things: IThing[]
}
var blopp: IStuff[] = [
{ name: "aa", things: [{ active: true }, { active: false }] },
{ name: "bb", things: null }];
Example 2: custom types in typescript
type Websites = 'www.google.com' | 'reddit.com';
let mySite: Websites = 'www.google.com'
let mySite: Website = 'www.yahoo.com'
type Details = { id: number, name: string, age: number };
let student: Details = { id: 803, name: 'Max', age: 13 };
let student: Details = { id: 803, name: 'Max', age: 13, address: 'Delhi' }
let student: Details = { id: 803, name: 'Max', age: '13' };