Skip to content

noUncheckedIndexedAccess w/ destructuring #56154

New issue

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

Closed
5 tasks done
arcanis opened this issue Oct 19, 2023 · 2 comments
Closed
5 tasks done

noUncheckedIndexedAccess w/ destructuring #56154

arcanis opened this issue Oct 19, 2023 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@arcanis
Copy link

arcanis commented Oct 19, 2023

πŸ” 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;
@MartinJohns
Copy link
Contributor

Partially a duplicate of #17390.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Oct 19, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants