After updating typescript
to version 3.7.4
, I find myself trying to modify my code.
My code is straightforward:
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.
...
}
I am looking to implement optional chaining
with destructuring
.
Does this feature exist now?