Skip to content

[prefer-destructuring] Variable declaration type annotation #723

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy