Skip to content
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

The paths setting in tsconfig.json causes issues #183

Closed
maxisam opened this issue Oct 13, 2017 · 21 comments
Closed

The paths setting in tsconfig.json causes issues #183

maxisam opened this issue Oct 13, 2017 · 21 comments
Labels

Comments

@maxisam
Copy link

maxisam commented Oct 13, 2017

I have TSLint (5.7.0), codelyzer (3.2.1) and angular lang service 0.1.7 installed on vscode 1.17.0 (windows)

In my angular cli (1.4.5) project

If I have the following setting in tsconfig

"paths": {
  "@app/*": ["app/*"],
  "@env/*": ["environments/*"]
},

and my import would be like
import { SharedModule } from '@app/shared/shared.module';

I will have lots of error like this in my template showing in vscode with red underlines.

[Angular] Property binding ngIf not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations".

But if I import it with relative path

import { SharedModule } from '../../shared/shared.module';

The problem goes away.

at first, I thought it was vscode-tslint https://github.com/Microsoft/vscode-tslint/issues/276#event-1292520818

But it seems like it is from Angular Language Service

@taos-thiagoaos
Copy link

Here i have the same problem.

@aitboudad
Copy link

aitboudad commented Oct 16, 2017

related to angular/angular#16382

@jahmani
Copy link

jahmani commented Oct 18, 2017

i have the same problem

  • vscode show error when using path alias
  • vs code show error when using *ngIf... in template

@juraj0137
Copy link

@maxisam Could you write here how you code structure looks like? Especially where app.module.ts and shared.module.ts are located. Do you use barels (index.ts)?

I would like to mention that if you use "paths" in yout tsconfig, you have to specify "baseUrl". (according to this stackoverflow answer)

@maxisam
Copy link
Author

maxisam commented Oct 18, 2017

root
|--src
|--app
|--share

I don't use barrels. It is a normal CLI layout. The project is generated by cli.

It has paths setting.

@Dunos
Copy link

Dunos commented Nov 13, 2017

Same issue here, the baseUrl parameter is already set with "src" and yet it does not work.

@ghost
Copy link

ghost commented Nov 16, 2017

This config solved the problem for me:

"baseUrl": "./",
"paths": {
  "@app/*": ["app/*"],
  "@env/*": ["environments/*"],
  "@services/*": ["app/modules/core/services/*"],
  "@models/*": ["app/models/*"],      
  "@components/*": ["app/components/*"],
  "@modules/*": ["app/modules/*"],
  "@core/*": ["app/modules/core/*"],
  "@shared/*": ["app/modules/shared/*"],
  "@features/*": ["app/modules/features/*"]
}

@ghiscoding
Copy link

I'm using Angular-CLI and also have this problem when using an external component library (which I'm the author). I tried to change the tsconfig.app.json with the mentioned config but that didn't change anything on my side. Is there any other workaround? And/or, do I have to do any kind of changes in my library?

@aitboudad
Copy link

@thiagoaos see angular/angular#16382 (comment)

@ghiscoding
Copy link

Thanks @aitboudad but that didn't work for me. I finally took the time to update my App to Angular 5 and updated as you suggested in that other issue to "@angular/language-service": "5.1.0-beta.1" but still get this error. It comes from a library that I made called Angular-Slickgrid and in my Dev environment using relative paths ./ I don't see this problem, but using the lib in an external App as import ... from 'angular-slickgrid' and switch to my View completely it becomes completely red as shown below.

You can see the error being

[Angular] Cannot read property 'isSkipSelf' of null

cannotskipitself

@aitboudad
Copy link

@ghiscoding after installing @angular/language-service you should restart vscode

@ghiscoding
Copy link

@aitboudad Yes I had done that too but still got the error.

@Dunos
Copy link

Dunos commented Nov 24, 2017

This is not working for me either, even after installing @angular/language-service

@ghost
Copy link

ghost commented Dec 11, 2017

I can also report the same problem. This is only occurring in VS Code with the language service extension. WebStorm has no problem with it by default and resolves everything.
See also: angular/angular#16382 and nrwl/nx#73.

@fxck
Copy link

fxck commented Jan 17, 2018

any updates on this?

@jwuliger
Copy link

Hello, I thought I was the only one.

I am working on an Angular Mono Repo, and this started happening to me a little while ago.

Hoping it gets fixed soon! Thanks, Guys!

@fxck
Copy link

fxck commented Mar 1, 2018

@chuckjaz any ideas?

@kyliau
Copy link
Contributor

kyliau commented Mar 7, 2018

angular/angular#16382 fixed this and it was released as Angular.ng-template 0.1.9. @fxck Can you please check if you're running the latest version?

@ghiscoding
Copy link

@kyliau
I don't see the issue on my side anymore, so I can confirm that it does work for me now. Thanks

@kyliau
Copy link
Contributor

kyliau commented Mar 7, 2018

Closing this for now since issue is fixed.

@kyliau kyliau closed this as completed Mar 7, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests