Closed as not planned
Description
π Search Terms
noUncheckedIndexedAccess, destructuring
β Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
β Suggestion
The !
qualifier should be allowed in destructuring patterns:
const [x!, y!, {z!}!] = someArrayValue;
π Motivating Example
This feature makes migrating a large codebase to noUncheckedIndexedAccess
easier, as we no longer need to migrate all existing destructuring patterns in one go.
π» Use Cases
We're working to enable noUncheckedIndexedAccess
on a very large codebase (10k+ files). I wrote a codemod adding the !
qualifier to existing unchecked accesses, but while it's easy to do this on foo[expr]
and foo.prop
nodes, I didn't find a good solution for destructured accesses:
const [x, y, {z}] = someArrayValue;
The following doesn't parse, where it seems it should:
const [x!, y!, {z!}!] = someArrayValue;