我刚刚升级了 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.
...
}
我想在使用 解构赋值
时使用 可选链
。
这个功能现在可用吗?