Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[prefer-destructuring] Variable declaration type annotation #723

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
ark120202 opened this issue Jul 18, 2019 · 2 comments
Closed

[prefer-destructuring] Variable declaration type annotation #723

ark120202 opened this issue Jul 18, 2019 · 2 comments
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: new base rule extension New base rule extension required to handle a TS specific case package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@ark120202
Copy link

const foo = { bar: 1 as const };
const bar: number = foo.bar;
// Currently fixed to
const { bar } = foo;
  1. Fixer should change code to const { bar }: { bar: number } = foo, removing type annotation is unsafe
  2. I think it would make sense to add an option to disable rule in this case, annotations on destructured variables aren't very pretty
@ark120202 ark120202 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jul 18, 2019
@bradzacher bradzacher added enhancement: new base rule extension New base rule extension required to handle a TS specific case and removed triage Waiting for team members to take a look labels Jul 18, 2019
@JoshuaKGoldberg JoshuaKGoldberg added the accepting prs Go ahead, send a pull request that resolves this issue label Oct 25, 2021
@armano2
Copy link
Collaborator

armano2 commented May 31, 2022

Playground

Code

const foo = { bar: 1 as const };
const bar: number = foo.bar;
// Currently fixed to
const { bar } = foo;

Eslint config

{
  "rules": {
    "prefer-destructuring": "error"
  }
}

@HolgerJeromin
Copy link

Can this issue be closed? ref PR #7117

@bradzacher bradzacher closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: new base rule extension New base rule extension required to handle a TS specific case package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

6 participants