摘要:
数字枚举 enum A { red, green, blue, } console.log(A.red); console.log(A.green); console.log(A.blue); 增长枚举 enum A { red=1, green, blue, } console.log(A.red 阅读全文
摘要:
// 元组, 需要严格按照元组声明的类型给值 let arr: [string, number] = ['1', 1] console.log(arr) console.log(arr[0]); let excel:[number, string][] = [ [0, '白云区'] ] 阅读全文
摘要:
抽象类被继承使用,抽象类中abstract修饰的方法不能有实现,实现抽象类的类需要实现抽象类中所有抽象方法 abstract class A { name: string constructor(name: string) { this.name = name } abstract run(time 阅读全文
摘要:
类定义 class Person { private name: string age: number constructor(name: string, age: number) { this.name = name this.age = age } display(): void { conso 阅读全文
摘要:
// 类型断言 interface A { name: string } interface B { age: string } let f1 = function(type: A|B): void { let x = (<A>type).name let y = (type as A).name 阅读全文
摘要:
数组 let arr: number[] = [1, 2, 3, 4,] let arr1: string[] = ["hello", "world"] let arr2: boolean[] = [true, false] let arr3: any[] = [1, '1', true] let 阅读全文
摘要:
接口 interface t1{ name:string } let obj:t1 = { name: "aoaoao" } console.log(obj); // 名字一样的接口会合并 interface t1{ name:string } interface t1 { age:number } 阅读全文
摘要:
编译工具 yarn global add ts-node yarn global add @types/node any let str: any = '123456' str = {} console.log(str) str = 123 console.log(str) unknow let s 阅读全文
摘要:
字符串 let str:string = '123456' 数字 let num: number = Infinity bool let b:boolean = Boolean(0) void let v:void = undefined any let n:any = null function 阅读全文