We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class Test { a: string; b: number; c() {} }
type ObjectKey<T> = keyof T
例
ObjectKey<Test> = 'a' | 'b' | 'c'
type ObjectValue<T> = T[keyof T]
ObjectValue<Test> = string | number | (() => void)
type ObjectPartial<T> = { [K in keyof T]?: T[K] };
ObjectPartial<Test> = class Test { a?: string; b?: number; c?() {} }
type ObjectDelete<T, D extends keyof T> = { [K in Exclude<keyof T, D>]: T[K] }; 例
type ObjectDelete<T, D extends keyof T> = { [K in Exclude<keyof T, D>]: T[K] };
ObjectDelete<Test> = class Test { b: number; c() {} }
type ObjectKeyFilterByValue<T, V> = { [K in keyof T]: T[K] extends V ? K : never }[keyof T];
例子
ObjectKeyFilterByValue<Test,string> = { a: string }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
预定义对象
类型为对象键名
例
类型为对象属性类型
例
转换对象属性为可选
例
去除对象属性
type ObjectDelete<T, D extends keyof T> = { [K in Exclude<keyof T, D>]: T[K] };
例
用对象属性类型过滤属性
例子
The text was updated successfully, but these errors were encountered: