Skip to content

[consistent-type-imports] Using with --fix changes constructor imports to type imports in nest and angular #3630

Closed
@yharaskrik

Description

@yharaskrik
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

https://github.com/yharaskrik/eslint-type-import-repro

yarn nx affected:lint --fix

Expected Result

I would expect that concrete classes that are needed for dependency injection, ClassType, would be left as non-type imports and the types that are not needed to be concrete are changed to type only imports, InterfaceType. I realize this is probably framework dependant since not everything uses DI and needs concrete classes at runtime.

Actual Result

As it stands the imports in app.service.ts are not using type imports. when running yarn nx affected:lint --fix (which uses eslint and @typescript-eslint under the hood) it changes the import to import type { ClassType, InterfaceType } from './type'; which then breaks the nest server as the ClassType is a concrete class that is needed for dependency injection.

Versions

package version
@typescript-eslint/eslint-plugin ^4.28.2
@typescript-eslint/parser ^4.28.2
TypeScript ~4.2.4
ESLint 7.22.0
node 12.22.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestpackage: parserIssues related to @typescript-eslint/parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions