Solvedangular Language Service: does not work with "paths" from .tsconfig

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
Set "paths" and "baseUrl" in tsconfig. for example:

"compilerOptions": {
  "baseUrl": "src",
  "paths": {
    "@myapp/*": [
        "app/*"
      ]
    },
}

Then import a component in a module using the path set via paths.

import {HeaderComponent} from  "@myapp/header/header.component";

Add {{foo}} to header.component.html. The error reported is "Unresolved variable or type foo".
The import seems to work fine, otherwise.

Expected behavior
The error should be: "Angular: Identifier 'foo' is not defined. The component declaration, template variable declarations, and element references do not contain such a member". This is the error that is reported if the import is done via a relative link, e.g, "./header/header.component"

Minimal reproduction of the problem with instructions
As described above.

What is the motivation / use case for changing the behavior?
To get proper errors via language service when using absolute paths for imports.

Please tell us about your environment:
PhpStorm 2017.1.3, MacOS 10.12.4.

  • Angular version: 4.1.0

  • Browser: N/A

  • Language: Typescript

  • Node (for AoT issues): node --version = 7.9.0

38 Answers

✔️Accepted Answer

I was getting this error, for the fix in tsconfig.json in root folder, I needed to set baseUrl to "src" and in the "path" the same paths in src/tsconfig.app.json. In src/tsconfig.app.json I've just added the paths and the baseUrl should be './'... Now it's everything working fine.

Other Answers:

I think this has been fixed by #20222, to try it install the beta version of language-service:

npm install --save-dev @angular/language-service@5.1.0-beta.1

Still present on angular 4.3.6. On vscode 1.15.1 i have few errors related to: Error encountered resolving symbol values statically of symbols declared through paths property on tsconfig.json file . Any eta here? Thanks.

I have the same problem. Trying to dig into it a bit more to see if I can find why

I'm with @karptonite, removing the @ does not fix issue.

More Issues: