元组(Tuple)
元素个数和类型固定的数组类型:
type Tuple = [number, string];
接口(Interface)
接口(Interface)
可以描述函数、对象、构造器的结构:
对象:
interface IPerson {name: string;age: number;}class Person implements IPerson {name: string;age: number;}class obj: Person = {name: 'guang',age: 18}
函数:
interface SayHello {(name: string): string}const func: SayHello = (name: string) => {return 'hello,' + name;}
构造器:
interface PersonConstructor {new (name: string, age: number): IPerson}function createPerson(ctor: Person)