typescript

共找到 5 篇文章

5 篇文章
4 分钟阅读
7500 字数
typescript

typescript 注解解读1

源注解代码 🔗 1 2 3 4 5 6 7 8 9 { readonly [K in keyof Defaults as K extends keyof T ? K : never]-?: K extends keyof T ? Defaults[K] extends undefined ? IfAny<Defaults[K], NotUndefined<T[K]>, T[K]> : NotUndefined<T[K]> : never } 解读 🔗 索引签名和可选性: readonly [K in keyof Defaults as ...] -?: readonly: 表示

typescript

typescript 装饰器

typescript 装饰器 🔗 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 declare type MethodDecorator = <T>( target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T> ) => TypedPropertyDescriptor<T> | void type VoidFn = ((...args: any[]) => void) | ((...args: any[]) => Promise<void>) export const Performance =

typescript

typescript 学习笔记

模式提取 🔗推导值类型 🔗 1 2 3 type p = Promise<"hello">; type MyGetValueResult<P> = P extends Promise<infer S> ? S : never; type pr = MyGetValueResult<p>; 推导数组元素 🔗 1 2 3 4 5 6 7 8 9 10 11 12 13 // First type f = [1, 2, 3]; type MyGetFirst<P extends unknown[]> = P extends [infer F,

阅读全文
2400 字
typescript

typescript 泛型类型

Partial 🔗可选类型, 把原本必选的参数都改成可选参数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 interface Crew { age: number; name: string; } const Jerry:Crew = { age: 10, name: 'jack' }; type AnonymousPeople = Partial<Crew>; const tom: AnonymousPeople = { name: 'Tom' }; keyof 🔗ke

阅读全文
1000 字