-
Notifications
You must be signed in to change notification settings - Fork 12k
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
VS Code auto imports are wrong for absolute paths in E2E files #12069
Comments
I'm sorry, but I don't think this is an issue caused by Angular CLI. As auto imports is not an Angular CLI feature, as it's provided by |
I think the question is how to get a |
Im also having this issue. My VS Code User Settings .json is set to non-relative paths:
So when I (auto) import a dependency.. the paths look like
When running I get this error:
How do we make e2e run with |
Hello I also have this issue when I run e2e test with absolute path. Anyone have a fix for that? |
Running The desire for smarter auto-import handling should be generally addressed by "solution style" tsconfigs in v10 which should make the editor a lot smarter about what files are associated with what |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Also asked in Stack Overflow
Versions
Angular CLI: 6.0.8
Node: 8.11.1
OS: win32 x64
Angular: 6.0.9
Repro steps
Create a new app using ng new
Setup baseUrl:"./src" in the tsconfig file
Import something to a file in src folder using autoimport
Result: import { smt1 } from "app/core/services/smt1"; (OK)
Import something to a file in e2e folder using autoimport
Result: import { smt2 } from "../e2e/smt2"; (NOK)
Auto import path is relative to the baseUrl of the tsconfig.json and cannot be resolved when running
the tests
Setup baseUrl: "." in tsconfig.json to have a common root for both src and e2e folders
Imports now look like this respectively:
import { smt1 } from "src/app/core/services/smt1"; (OK)
import { smt2 } from "src/e2e/smt2"; (OK)
Run npm run e2e
Cannot find name 'smt2'.
at createTSError (\node_modules\ts-node\src\index.ts:261:12)
at getOutput (\node_modules\ts-node\src\index.ts:367:40)
at Object.compile (\node_modules\ts-node\src\index.ts:557:11)
at Module.m._compile (\node_modules\ts-node\src\index.ts:439:43)
at Module._extensions..js (module.js:663:10)
at Object.require.extensions.(anonymous function) [as .ts] (node_modules\ts-node\src\index.ts:442:12)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
Desired functionality
baseUrl: "." in tsconfig.json should enable us to have root folder of the app as the base both in e2e and src folders.
Other option would be to configure autoimports for src and e2e files separately, so that we can use absolute paths in src and relative in e2e folders.
The text was updated successfully, but these errors were encountered: