Skip to content

Latest commit

 

History

History
44 lines (39 loc) · 574 Bytes

File metadata and controls

44 lines (39 loc) · 574 Bytes

Class

interface ExampleInterface{
	foo: string;
	bar: number;
}

class Example implements ExampleInterface{
	foo: string;
	bar: number;

	constructor(init: ExampleInterface){
		this.foo = init.foo;
		this.bar = init.bar;
	}
}

Generic

class Example<T>{
	item: T;

	constructor(item: T){
		this.item = item;
	}
}

Optional

class Example<T = {}>{
	item: T;

	constructor(item: T){
		this.item = item;
	}
}

Type Utility

Array Element

Get array item type

export type ArrayElement<T> = T extends (infer U)[] ? U : null;