摘要:
Partial 为所有属性添加?这个midfier,也就是设置所有属性都是可选属性。 interface Person{ name: string; age: number; } type NewPerson = Partial<Person>; const p: NewPerson = { nam 阅读全文
posted @ 2020-12-25 16:19
ashen1999
阅读(914)
评论(0)
推荐(0)
摘要:
type能为基本类型起别名 type aliaName = string; type能实现联合类型 interface Dog{ wang(); } interface Cat{ miao(); } type Pet = Dog | Cat; type实现元组类型 type PetList = [D 阅读全文
posted @ 2020-12-25 15:28
ashen1999
阅读(436)
评论(0)
推荐(0)
摘要:
类似于any,但是更安全。需要通过类型范围缩小,才能使用 如: const a: unknown = 10; if(typeof a 'string'){ console.log(a.tolocalString) } 在上例中,只有string类型的a,才能被输出。 阅读全文
posted @ 2020-12-25 15:22
ashen1999
阅读(859)
评论(0)
推荐(0)