-
Notifications
You must be signed in to change notification settings - Fork 12k
tsconfig "paths" config is not recognized #3837
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
Comments
Are you using |
No, just plain |
Well, it should work then. I'am use the same config. (But with beta.22 version. Still have not time for update.) |
Thanks for letting me know that it was supported. I was chasing rabbit trails trying to get angular-cli to support it, but turns out it IS supported already. I simply had my paths wrong. |
Also, for posterity, I had to make the paths be an array. It looks like Typescript accepts a string, but angular-cli expects it to be an array.
|
Ok, that works fine for the main app, but my tests don't seem to recognize it.
Here is the
Are the |
Sorry for commenting here, but this isn't working for me. I added baseUrl and paths to tsconfig.json just like the OP posted, but
|
@Parziphal I don't know what's going on in your setup, but if you can reproduce in a new project then I ask you to open a new issue with the reproduction. If it does work there, then have a look at how all the tsconfig.json might differ from yours. |
I believe this regressed. I had the following setup in [root]/tsconfig.json:
and then in my files I referenced packages in |
Hi, I have the same problem. I am in a fresh project. With this setup:
And after set the paths:
I try to run
|
Maybe related to #7341, although for me |
I'm having an issue where the app builds and runs fine but non-relative paths are not resolved in VS Code. Here's my setup:
tsconfig.json
tsconfig.app.json
|
I still haven't figured this out completely, but I have a workaround. This may be a windows-specific problem. This does not work:
This does work (baseURL moves up one directory, paths moves down):
Hope that helps someone. I may try to track down the specific problem, but it's not a typescript problem; trying a generic |
@duncanwerner I used your idea and got it to work on Mac. Seems like the builder uses tsconfig:
tsconfig.app
|
I seems like the error was that |
|
Yeah, I mean the error was that I wasn't aware of the overwriting, not that "the file is overwriting my config, that's an error, how dare that file!". Now I just found a little thing. The IDE (vscode) doesn't show any suggestions while I type a path using the alias (so it won't autocomplete, I have to write the full path). Is there a way to fix this? Not that it's too important but... if it can be fixed it'd be nice. |
vscode (or presumably any other editor, but that's what I use as well) uses the root |
Does it autocomplete to you? Because it doesn't here. I restarted the editor, and I made sure the path is correctly relative to the root |
Sorry, I misunderstood. It does not autocomplete aliased paths. File a feature request over at the vscode repo. |
I have a problem similar to this when I run the tests E2E Angular CLI version:
tsconfig.json
tsconfig.e2e.json
Error: |
I have the same problem as @ivanguimam mentioned, has anyone solved this? My app works fine but my e2e tests crashing every time when I try to start them with path variables. |
I am having trouble getting paths to work when building packages. ie in the tsconfig.lib.json
to tsconfig.lib.json and then try to utilise it with a path such as
the target file is |
@Bengreen, may I suggest you open a new issue with a small reproduction if you feel it’s a bug. That said when building packages you should not reference files like you showed above but rather the entrypoint aka the library |
@ivanguimam I have the same problem. Did you find the solution? |
@YuriiZadorozhnyi no I just left the E2E tests aside because I had a deadline to deliver the project and could not continue to run after a solution to this problem... |
is this broken for anybody in Angular 7? I don't see paths anymore in https://angular.io/api/core/CompilerOptions |
Reading all the above and seeing all related closed issue and yet it still seems to be a thing in Angular 7 as @seabass223 has mentioned |
I found that if I incorrectly change one of my path values to a string rather than an array,
to
during ng serve I get the error
It looks like it's looking in node_models for @service instead of trying to map it.
any help is much appreciated in solving this. |
Try: |
I think I've got it fixed now Setup
The above compiles fine with no errors. When we add barrel files in order to simplify our importssrc/app/service/index.ts
src/app/service/sub/index.ts
and change app.component.ts imports to
ResolutionIf we remove the final * in tsconfig.json paths
|
Also please see here for details on TypeScript module resolution and path mapping: https://www.typescriptlang.org/docs/handbook/module-resolution.html |
thanks for the response. I tried |
that does work great since your mapping directly to individual files, but may still fail when using the
I was able to fix it finally by setting my tsconfig (tsconfig.app.json has no baseUrl or Paths because it only extends tsconfig)
and appropriately using index.ts files just like node_modules/@angular does. |
I'm having a similar problem after updating to angular 7.0.4. I do not use angular cli for my project, but I am convinced it is ngtools/webpack causing the problem. The relevant portions of my tsconfig look like this:
This builds but with 2 big caveats.
I've run I'm not sure why this changed between 6 and 7, since there was no mention of any changes around tsconfig in any of the Changelogs. Anyone else still stuck after following the advice in this thread? |
@seabass223 it works for me with and the imports works fantastic |
Super quick update: With the same I'm not super happy with this resolution, but once the Angular team fixes this issue, it should be pretty easy to do another find and replace to remove the |
@seabass223 maybe this is the correct docs for CompilerOptions --> https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping |
In my case |
I commented out
|
@ivanguimam Did you find solution for this? |
@Bengreen I have the same problem. Did you find the solution? |
Came here b/c I just experienced this same issue. I pieced together a work around from @swimmadude66 solution. For anyone else: tsconfig.json compiler options looks like this:
When importing a service anywhere, I do this:
There are no more circular dependency warnings after this. |
while migration from mono app to multi app we should look at baseurl in tsconfig.json |
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. |
Mac OSX Sierra
angular-cli version 1.0.0-beta.24
I'm trying to configure things so I don't have to use ugly (and brittle) relative paths when including modules from my own project. I modified tsconfig.json to include:
And that works great for TypeScript.
However, "ng serve" is throwing this error:
I've discovered that Webpack has configuration options for this, but I can't figure out how to configure Webpack through Angular-CLI to support this. Is this a bug, or is this feature not exposed?
The text was updated successfully, but these errors were encountered: