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
export type T = 'key1' | 'key2' | 'key3'; export type Bar = { [key in T]: string; };
相关参考
The text was updated successfully, but these errors were encountered:
TypeScript 3.7版本才可使用
使用场景当不确定值为 null 或 undefined 的时候,可以使用 ?.
例如:
let x = foo?.bar.baz(); // 相当于 let x = (foo === null || foo === undefined) ? undefined : foo.bar.baz();
Sorry, something went wrong.
使用场景: 要给一个值默认值的时候可使用,主要替换 let a = b || 'aa';
let a = b || 'aa';
let x = foo ?? bar(); let x = (foo !== null && foo !== undefined) ? foo : bar();
No branches or pull requests
如何定义指定Key的对象类型
相关参考
The text was updated successfully, but these errors were encountered: