8000 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

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
4 tasks done
somebody1234 opened this issue Aug 24, 2023 · 4 comments · Fixed by #7722
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@somebody1234
Copy link

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

@somebody1234 somebody1234 added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Aug 24, 2023
@JoshuaKGoldberg JoshuaKGoldberg added good first issue Good for newcomers accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Sep 14, 2023
@rielAsh24
Copy link
Contributor

Hey @JoshuaKGoldberg @somebody1234 . I'd be glad to look into this!

@rielAsh24
Copy link
Contributor
rielAsh24 commented Oct 2, 2023

A quick question; I wish to test the repro code against my changes. Do I need to add another test or does passing the tests in the codebase suffice?

Context: I saw a fixture for the tests which looks similar to the repro code, so was wondering if adding a test is necessary.

@bradzacher
Copy link
Member

With any change we require new tests to ensure the new code is working as expected!

@rielAsh24
Copy link
Contributor

With any change we require new tests to ensure the new code is working as expected!

I have already added a test case in the pull request, so if there's more required, I can surely work on it.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 19, 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 bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
4 participants
0