10000 Bug: [consistent-type-imports] Incorrectly suggests `import type` on import assertion · Issue #7527 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content
Bug: [consistent-type-imports] Incorrectly suggests import type on import assertion #7527
Closed
@somebody1234

Description

@somebody1234

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched 6A83 for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.9.3&showAST=es&fileType=.tsx&code=JYWwDg9gTgLgBAKjgQwM4oFKogOzgMyghDgHIA6AemXICtsdSVVUBTWOAbzhgE8xWALjL1cTAL4AoSQGNcqeAHcAFshjDkWXOQCCAbiA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6MgeyeUuX0Ra0ipWpQC2xDtHyoMkRNGhTI4MAF8QaoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

import * as aJson from './a.json' assert { type: 'json' }

const what: aJson.A;

ESLint Config

{
  "rules": {
    "@typescript-eslint/consistent-type-imports": "error"
  }
}

tsconfig

No response

Expected Result

No error

Actual Result

Error. When fixing it, TypeScript says Import assertions cannot be used with type-only imports or exports. ts(2822).

Importantly, the autofix "fixes" it into invalid TypeScript code.

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerspackage: 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

      0