question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

imports to variable with same name in constructor

See original GitHub issue

If you name a variable the same as an import in typescript, like this:

import {Service} from "..."
constructor(private Service: Service) {}

The plugin will report Service as an unused import. If you run --fix the import is removed, which is wrong.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lelonek1commented, Jun 2, 2020

For others who have this problem, the upstream meta-issue tracking the changes needed to fix this is https://github.com/typescript-eslint/typescript-eslint/issues/1856.

0reactions
sweeplinecommented, May 4, 2020

I took another look and it’s definitely an upstream issue, closing… I will report upstream, but you should not name your variables with PascalCase anyway 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I use the same variable name of a ... - Stack Overflow
So I was wondering if I could declare an instance field(ex. str1) and a parameter with the same name. Basicly, I ran something...
Read more >
Passing Information to a Method or a Constructor
A parameter can have the same name as one of the class's fields. If this is the case, the parameter is said to...
Read more >
Export and Import - The Modern JavaScript Tutorial
We can label any declaration as exported by placing export before it, be it a variable, function or a class. For instance, here...
Read more >
constructor - JavaScript - MDN Web Docs - Mozilla
The constructor method is a special method of a class for creating and initializing an object instance of that class.
Read more >
2.2. Creating and Initializing Objects: Constructors
When this code executes, it creates a new object of the specified class and calls a constructor, which has the same name as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found