【发布时间】:2023-03-07 03:14:01
【问题描述】:
我刚刚将typescript 更新为3.7.4,我正在尝试编辑我的代码。
我有一个简单的代码
interface Test
event: {
queryStringParameters: { [name: string]: string } | null;
}
}
const test:Test = (event) => {
// const { no } = event?.queryStringParameters; //Property 'no' does not exist on type '{ [name: string]: string; } | null'.ts(2339)
const no = event?.queryStringParameters?.no; //It works but I want to use above that.
...
}
我想将optional chaining 与destructuring 一起使用。
现在有这个功能吗?
【问题讨论】:
标签: typescript