admin管理员组

文章数量:1356225

I would like VS Code to show auto-import suggestions even if there is an instance with the same name in the current file I'm in.

In the screenshot below, you'll see a simple dependency injection example of the issue. Notice that when the instance name is the same as the class I'm trying to import, VS Code displays the error:

'LogSvc' refers to a value, but is being used as a type here.

Instead, I would've expected this class to be auto-imported when all the other classes were auto-imported.

Additionally, when I access the quick actions on the class, the option to import the class isn't visible:

I can change the name of the instance and importing the class is then added to the quick actions and the auto-import works fine...

But I shouldn't have to (nor do I understand why) I have to do that.

本文标签: visual studio codeHow to autoimport class with same name as instanceStack Overflow