js的原型链 prototype
TS常用技巧
为window添加字段
// 给Window添加字段
declare interface Window {
flag: string, // 给Window添加这个字段
apple: string | number, // 给Window添加这个字段
}为无声明文件的第三方包添加声明
// 可以给qs这个无类型的第三方包声明类型,声明成了any
declare module 'qs';字符串数组生成type
const arr = ['apple', 'car', 'tree']
// 目标,根据上面的现有的数组,得到下面的类型
type Arr = 'apple' | 'car' | 'tree'把对象的key生成type
Last updated