I'm having strange issue when auto importing services/components from folder provided with path alias within Angular 9 application.
Those are my aliases defined in tsconfig.json
"paths": {
"@core/*": ["app/core/*"],
"@shared/*": ["app/shared/*"],
"@state/*": ["app/state/*"]
}
Then in Core folder I'm reexporting all services in index file (app/core/index.ts)
export * from './sse/sse.service';
export * from './rack/rack.service';
Now when I'm injecting the service in a constructor the provided auto import option gets imported with faulty path:
// Incorrect - auto imported path
import { RackService } from '@core/';
// Correct path after manual fix
import { RackService } from '@core/index';
It's just a minor issue but quite annoying at the same time and I'm not sure whether it's some incorrect configuration on my side, or VS Code issue. Any idea? Could it be caused by JEST as I'm using it instead of Jasmine and it requires to have aliases defined in package.json also.
"jest": {
"preset": "jest-preset-angular",
"setupFilesAfterEnv": [
"./src/setup-jest.ts"
],
"moduleNameMapper": {
"^@core/(.*)$": "<rootDir>/src/app/core/$1",
"^@shared/(.*)$": "<rootDir>/src/app/shared/$1",
"^@state/(.*)$": "<rootDir>/src/app/state/$1"
}
},