Skip to content
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

[consistent-type-imports] Issues with Angular's Dependency Injection #2713

Closed
3 tasks done
lachieh opened this issue Oct 27, 2020 · 2 comments
Closed
3 tasks done

[consistent-type-imports] Issues with Angular's Dependency Injection #2713

lachieh opened this issue Oct 27, 2020 · 2 comments
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@lachieh
Copy link

lachieh commented Oct 27, 2020

  • 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

{
  "rules": {
    "@typescript-eslint/consistent-type-imports": 'error'
  }
}
import { ApiService } from '@app/core';

@Component({
  selector: 'app-details',
  templateUrl: './details.component.html'
})
export class RuleDetailsComponent implements OnChanges {
  constructor(private api: ApiService) {}
}

Expected Result
I expected the imports not to be replaced with Type Only imports

Actual Result

Injected dependencies are replaced with type only imports

import type { ApiService } from '@app/core';

This causes errors in compilation like this:

    ERROR in src/app/rules/rule-details/rule-details.component.ts:20:61 - error NG2003: No suitable injection token for parameter 'dialog' of class 'RuleDetailsComponent'.
      Consider changing the type-only import to a regular import, or use the @Inject decorator to specify an injection token.

Additional Info
I have a feeling this is also related to #2559. I am unfamiliar with NestJS it seems like they handle dependency injection in a similar manner.

Versions

package version
@typescript-eslint/eslint-plugin 4.5.0
@typescript-eslint/parser 4.5.0
TypeScript 4.0.3
ESLint 7.12.0
node 14.4.0
@angular/core 10.2.0
@lachieh lachieh added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Oct 27, 2020
@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for maintainers to take a look labels Oct 27, 2020
@bradzacher
Copy link
Member

duplicate of #2559

@lachieh
Copy link
Author

lachieh commented Oct 27, 2020

Thanks, I'll follow progress there.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants