常用类型


ReturnType

InstanceType

Parameters

Omit, Exclude, Extract, Pick, Required

closestElementabstract new (...args: any) => any>(constructor: K): InstanceType | null;

让编辑器有提示:type LiteralType = 'cat' | 'dog' | (string & {})

type ElementOf = T extends (infer E)[] ? E : never

type Json = null | boolean | number | string | Json[] | { [prop: string]: Json }


const list = ['a', 'b', 'c'] as const; // TS3.4 syntax
type NeededUnionType = typeof list[number]; // 'a'|'b'|'c';