![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ts
aminwangaa
终究是走上了勤能补拙的路~~~
展开
-
Typescript学习 泛型工具类型
typeof 获取一个变量或对象的类型interface Person { name: string age: number}const amin: Person = { name: "amin", age: 17}type Amin = typeof amin // type Amin = Personconst person: Amin = { // const person: Person name: "小明", age: 18}t原创 2020-12-03 11:18:17 · 409 阅读 · 0 评论 -
Typescript学习 交叉类型 函数重载
同名基础类型属性的合并interface X { c: string d: string}interface Y { c: string e: number}type XY = X & Ytype YX = Y & Xlet p: XYlet q: YXp = { c: "a", d: "a", e: 5}q = { c: "a", d: "a", e: 5 }同名非基础类型原创 2020-11-25 16:28:31 · 203 阅读 · 0 评论 -
Typescript学习 类型守卫
in 关键字interface Admin { name: string privileges: string[]}interface Employee { name: string startDate: Date}type UnKnownEmployee = Employee | Adminfunction printEmployeeInformation(emp: UnKnownEmployee) { console.log("Name: " +原创 2020-11-25 11:20:47 · 165 阅读 · 0 评论 -
Typescript学习 断言
类型断言// 尖括号定义类型let value: any = "this is a string"let valueLen: number = <string>Value.length// as 强制转换类型let str: any = "this is a string"let strLen: number = (str as string).length// 非空断言function myFunc(mayBeString: string | undefined | nul原创 2020-11-25 09:59:35 · 395 阅读 · 0 评论