Skip to content

[prefer-destructuring] Variable declaration type annotation #723

Closed
@ark120202

Description

@ark120202
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: new base rule extensionNew base rule extension required to handle a TS specific casepackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions