1

This question is more about how deep inside ng generate command works. I am using Visual Studio Code to develop an Angular project. I am generating components and services using the terminal section of the IDE itself.

So, I created a service using the ng g s command while specifying the path, like below:

$ ng g s services/logger/logger

As expected, the aforementioned command created the service and spec files like this:

 1. src/app/services/logger/logger.service.ts
 2. src/app/services/logger/logger.service.spec.ts

Everything was fine. Then I thought of renaming the service folder name by uppercasing the first letter. So I made the folder like this:

 1. src/app/services/Logger/logger.service.ts
 2. src/app/services/Logger/logger.service.spec.ts

Now whenever I am trying to import this service by using "Quick Fix" or IDE suggestions, VSCode always mention the import statement as

import { LoggerService } from '../logger/logger.service';

It grabbed my attention when the IDE cried out about the wrong path saying everything is almost same but the casing of one letter. If I manually change the text to '../Logger/logger.service' it works.

My question is why? Why would the IDE suggest the original path that I mentioned in the command line?

I tried to find traces of the service name or path info in the source code. But I couldn't find. Does VSCode notes down the original result of the ng command? Or is it saved somewhere in the local .angular folder?

I tried to close the IDE and reopen to see if it still suggests the old path. Yes, it does.

I thought it would be interesting to know the internal works.

Any idea?

sanjeev
  • 458
  • 1
  • 6
  • 15
  • 2
    Are you working on Windows? Windows has a big problem with cases. If you create a file in lower case and rename it to upper case, strange things happen and applications break, when you share your code with others or run it in a CI pipeline. It seems like the display name changes but the actual node name on the file system doesn't change. This problem is unrelated to Angular's internals. It's just Windows. My solution was switching to Linux. – jabaa Apr 26 '23 at 18:05
  • I reproduce it on Windows but when i close VSCode and open it again worked for me. – Kostas Nitaf Apr 27 '23 at 11:27
  • So, it seems VScode is storing some information. It's interesting if VSCode actually monitors what we input in the integrated command window. – sanjeev May 05 '23 at 16:30

0 Answers0