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

v0.1000.0 does not support solution-style tsconfig #824

Closed
keatkeat87 opened this issue Jun 21, 2020 · 33 comments
Closed

v0.1000.0 does not support solution-style tsconfig #824

keatkeat87 opened this issue Jun 21, 2020 · 33 comments
Labels

Comments

@keatkeat87
Copy link

image

To Reproduce

Steps to reproduce the behavior:
git clone https://github.com/keatkeat87/angular-10rc6-language-service-issue.git
yarn install
check app.component.html

Expected behavior
should able to F12 go to component definition.

Angular CLI: 10.0.0-rc.5
Node: 12.18.0
OS: win32 x64

Angular: 10.0.0-rc.6
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package Version

@angular-devkit/architect 0.1000.0-rc.5
@angular-devkit/build-angular 0.1000.0-rc.5
@angular-devkit/build-optimizer 0.1000.0-rc.5
@angular-devkit/build-webpack 0.1000.0-rc.5
@angular-devkit/core 10.0.0-rc.5
@angular-devkit/schematics 10.0.0-rc.5
@angular/cdk 10.0.0-rc.2
@angular/cli 10.0.0-rc.5
@angular/material 10.0.0-rc.2
@ngtools/webpack 10.0.0-rc.5
@schematics/angular 10.0.0-rc.5
@schematics/update 0.1000.0-rc.5
rxjs 6.5.5
typescript 3.9.5
webpack 4.43.0

@keatkeat87 keatkeat87 added the bug label Jun 21, 2020
@ayazhafiz
Copy link
Member

Can you please provide the extension output and logs?

@keatkeat87
Copy link
Author

keatkeat87 commented Jun 21, 2020

how to do it ?

@ayazhafiz
Copy link
Member

Sure, see the “Logs” section in the issue template:

Please attach two logs:

Console output (Go to toolbar --> View --> Output, and copy the contents)
Log file (Path is printed to the console output at startup)

@keatkeat87
Copy link
Author

[Info - 7:35:19 am] Angular language server process ID: 16852
[Info - 7:35:19 am] Using typescript v3.8.3 from c:\Users\keatk.vscode\extensions\angular.ng-template-0.901.11\node_modules\typescript\lib\tsserverlibrary.js
[Info - 7:35:19 am] Using @angular/language-service v9.1.11 from c:\Users\keatk.vscode\extensions\angular.ng-template-0.901.11\server\node_modules@angular\language-service\bundles\language-service.umd.js
[Info - 7:35:19 am] Log file: c:\Users\keatk\AppData\Roaming\Code\logs\20200622T073458\exthost1\Angular.ng-template\nglangsvc.log
[Info - 7:35:29 am] Disabling language service for c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json because it is not an Angular project ('@angular/core/core.d.ts' could not be found). If you believe you are seeing this message in error, please reinstall the packages in your package.json.
[Error - 7:35:29 am] No config file for c:\keatkeat\my projects\angular\10.0\simple-test\src\app\app.component.ts

@ayazhafiz
Copy link
Member

Okay, thanks. Looks like your extension version is not using the version 10 rc. If you would like to use an Angular 10 app with the VSCode Angular language service extension, you will need to load install v0.1000.0-rc of the extension. Instructions for how to do this can be found at #793 (comment).

Let me know if that resolves your issue.

@keatkeat87
Copy link
Author

keatkeat87 commented Jun 22, 2020

i just done the installation, but it still not working.

image

Log output

Log:
Info 0 [8:0:52.551] Format host information updated
Info 1 [8:0:52.552] reload projects.
Info 2 [8:0:52.552] Before ensureProjectForOpenFiles:
Info 3 [8:0:52.552] After ensureProjectForOpenFiles:
Info 4 [8:0:52.552] Host file extension mappings updated
Info 5 [8:0:52.567] Search path: c:/keatkeat/my projects/angular/10.0/simple-test/src/app
Info 6 [8:0:52.569] For info: c:/keatkeat/my projects/angular/10.0/simple-test/src/app/app.component.html :: Config file name: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json
Info 7 [8:0:52.570] Opened configuration file c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json
Info 8 [8:0:52.587] Config: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json : {
"rootNames": [],
"options": {
"configFilePath": "c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json"
},
"projectReferences": [
{
"path": "c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.app.json",
"originalPath": "./tsconfig.app.json"
},
{
"path": "c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.spec.json",
"originalPath": "./tsconfig.spec.json"
},
{
"path": "c:/keatkeat/my projects/angular/10.0/simple-test/e2e/tsconfig.json",
"originalPath": "./e2e/tsconfig.json"
}
]
}
Info 9 [8:0:52.588] Loading global plugin @angular/language-service
Info 10 [8:0:52.588] Enabling plugin @angular/language-service from candidate paths: c:\Users\keatk.vscode\extensions\angular.ng-template-0.1000.0-rc.1\server\node_modules@angular\language-service\bundles\language-service.umd.js,c:/Users/keatk/.vscode/extensions/angular.ng-template-0.1000.0-rc.1/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 11 [8:0:52.589] Loading @angular/language-service from c:\Users\keatk.vscode\extensions\angular.ng-template-0.1000.0-rc.1\server\node_modules@angular\language-service\bundles\language-service.umd.js (resolved to c:/Users/keatk/.vscode/extensions/angular.ng-template-0.1000.0-rc.1/server/node_modules/@angular/language-service/bundles/language-service.umd.js/node_modules)
Info 12 [8:0:52.724] Plugin validation succeded
Info 13 [8:0:52.761] Starting updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json
Info 14 [8:0:52.830] Finishing updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json Version: 1 structureChanged: true Elapsed: 69ms
Info 15 [8:0:52.830] Project 'c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json' (Configured)
Info 16 [8:0:52.830] Files (0)

Info 17 [8:0:52.830] -----------------------------------------------
Info 18 [8:0:52.831] Starting updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json
Info 19 [8:0:52.832] Finishing updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json Version: 2 structureChanged: false Elapsed: 1ms
Info 20 [8:0:52.835] Disabling language service for c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.json because it is not an Angular project ('@angular/core/core.d.ts' could not be found). If you believe you are seeing this message in error, please reinstall the packages in your package.json.
Info 21 [8:0:52.835] Opened configuration file c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.app.json
Info 22 [8:0:52.848] Config: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.app.json : {
"rootNames": [
"c:/keatkeat/my projects/angular/10.0/simple-test/src/main.ts",
"c:/keatkeat/my projects/angular/10.0/simple-test/src/polyfills.ts"
],
"options": {
"baseUrl": "c:/keatkeat/my projects/angular/10.0/simple-test",
"outDir": "c:/keatkeat/my projects/angular/10.0/simple-test/out-tsc/app",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": 2,
"importHelpers": true,
"target": 2,
"module": 6,
"lib": [
"lib.es2018.d.ts",
"lib.dom.d.ts"
],
"types": [],
"configFilePath": "c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.app.json"
}
}
Info 23 [8:0:52.849] Loading global plugin @angular/language-service
Info 24 [8:0:52.849] Enabling plugin @angular/language-service from candidate paths: c:\Users\keatk.vscode\extensions\angular.ng-template-0.1000.0-rc.1\server\node_modules@angular\language-service\bundles\language-service.umd.js,c:/Users/keatk/.vscode/extensions/angular.ng-template-0.1000.0-rc.1/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 25 [8:0:52.849] Loading @angular/language-service from c:\Users\keatk.vscode\extensions\angular.ng-template-0.1000.0-rc.1\server\node_modules@angular\language-service\bundles\language-service.umd.js (resolved to c:/Users/keatk/.vscode/extensions/angular.ng-template-0.1000.0-rc.1/server/node_modules/@angular/language-service/bundles/language-service.umd.js/node_modules)
Info 26 [8:0:52.862] Plugin validation succeded
Info 27 [8:0:52.865] Starting updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.app.json
Info 28 [8:0:56.426] Finishing updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.app.json Version: 1 structureChanged: true Elapsed: 3561ms
Info 29 [8:0:56.426] Project 'c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.app.json' (Configured)
Info 30 [8:0:56.426] Files (307)

Info 31 [8:0:56.426] -----------------------------------------------
Info 32 [8:0:56.427] Starting updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.app.json
Info 33 [8:0:56.432] Finishing updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.app.json Version: 2 structureChanged: false Elapsed: 5ms
Info 34 [8:0:56.434] Opened configuration file c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.spec.json
Info 35 [8:0:56.449] Config: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.spec.json : {
"rootNames": [
"c:/keatkeat/my projects/angular/10.0/simple-test/src/test.ts",
"c:/keatkeat/my projects/angular/10.0/simple-test/src/polyfills.ts"
],
"options": {
"baseUrl": "c:/keatkeat/my projects/angular/10.0/simple-test",
"outDir": "c:/keatkeat/my projects/angular/10.0/simple-test/out-tsc/spec",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": 2,
"importHelpers": true,
"target": 2,
"module": 6,
"lib": [
"lib.es2018.d.ts",
"lib.dom.d.ts"
],
"types": [
"jasmine"
],
"configFilePath": "c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.spec.json"
}
}
Info 36 [8:0:56.450] Loading global plugin @angular/language-service
Info 37 [8:0:56.450] Enabling plugin @angular/language-service from candidate paths: c:\Users\keatk.vscode\extensions\angular.ng-template-0.1000.0-rc.1\server\node_modules@angular\language-service\bundles\language-service.umd.js,c:/Users/keatk/.vscode/extensions/angular.ng-template-0.1000.0-rc.1/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 38 [8:0:56.450] Loading @angular/language-service from c:\Users\keatk.vscode\extensions\angular.ng-template-0.1000.0-rc.1\server\node_modules@angular\language-service\bundles\language-service.umd.js (resolved to c:/Users/keatk/.vscode/extensions/angular.ng-template-0.1000.0-rc.1/server/node_modules/@angular/language-service/bundles/language-service.umd.js/node_modules)
Info 39 [8:0:56.464] Plugin validation succeded
Info 40 [8:0:56.466] Starting updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.spec.json
Info 41 [8:0:57.389] Finishing updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.spec.json Version: 1 structureChanged: true Elapsed: 923ms
Info 42 [8:0:57.389] Project 'c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.spec.json' (Configured)
Info 43 [8:0:57.389] Files (99)

Info 44 [8:0:57.389] -----------------------------------------------
Info 45 [8:0:57.390] Starting updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.spec.json
Info 46 [8:0:57.391] Finishing updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/tsconfig.spec.json Version: 2 structureChanged: false Elapsed: 1ms
Info 47 [8:0:57.392] Opened configuration file c:/keatkeat/my projects/angular/10.0/simple-test/e2e/tsconfig.json
Info 48 [8:0:57.399] Config: c:/keatkeat/my projects/angular/10.0/simple-test/e2e/tsconfig.json : {
"rootNames": [
"c:/keatkeat/my projects/angular/10.0/simple-test/e2e/src/app.e2e-spec.ts",
"c:/keatkeat/my projects/angular/10.0/simple-test/e2e/src/app.po.ts"
],
"options": {
"baseUrl": "c:/keatkeat/my projects/angular/10.0/simple-test",
"outDir": "c:/keatkeat/my projects/angular/10.0/simple-test/out-tsc/e2e",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": 2,
"importHelpers": true,
"target": 5,
"module": 1,
"lib": [
"lib.es2018.d.ts",
"lib.dom.d.ts"
],
"types": [
"jasmine",
"jasminewd2",
"node"
],
"configFilePath": "c:/keatkeat/my projects/angular/10.0/simple-test/e2e/tsconfig.json"
}
}
Info 49 [8:0:57.400] Loading global plugin @angular/language-service
Info 50 [8:0:57.400] Enabling plugin @angular/language-service from candidate paths: c:\Users\keatk.vscode\extensions\angular.ng-template-0.1000.0-rc.1\server\node_modules@angular\language-service\bundles\language-service.umd.js,c:/Users/keatk/.vscode/extensions/angular.ng-template-0.1000.0-rc.1/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 51 [8:0:57.400] Loading @angular/language-service from c:\Users\keatk.vscode\extensions\angular.ng-template-0.1000.0-rc.1\server\node_modules@angular\language-service\bundles\language-service.umd.js (resolved to c:/Users/keatk/.vscode/extensions/angular.ng-template-0.1000.0-rc.1/server/node_modules/@angular/language-service/bundles/language-service.umd.js/node_modules)
Info 52 [8:0:57.421] Plugin validation succeded
Info 53 [8:0:57.424] Starting updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/e2e/tsconfig.json
Info 54 [8:0:58.886] Finishing updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/e2e/tsconfig.json Version: 1 structureChanged: true Elapsed: 1462ms
Info 55 [8:0:58.886] Project 'c:/keatkeat/my projects/angular/10.0/simple-test/e2e/tsconfig.json' (Configured)
Info 56 [8:0:58.886] Files (123)

Info 57 [8:0:58.886] -----------------------------------------------
Info 58 [8:0:58.887] Starting updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/e2e/tsconfig.json
Info 59 [8:0:58.889] Finishing updateGraphWorker: Project: c:/keatkeat/my projects/angular/10.0/simple-test/e2e/tsconfig.json Version: 2 structureChanged: false Elapsed: 2ms
Info 60 [8:0:58.890] Disabling language service for c:/keatkeat/my projects/angular/10.0/simple-test/e2e/tsconfig.json because it is not an Angular project ('@angular/core/core.d.ts' could not be found). If you believe you are seeing this message in error, please reinstall the packages in your package.json.
Info 61 [8:0:58.891] Loading global plugin @angular/language-service
Info 62 [8:0:58.891] Enabling plugin @angular/language-service from candidate paths: c:\Users\keatk.vscode\extensions\angular.ng-template-0.1000.0-rc.1\server\node_modules@angular\language-service\bundles\language-service.umd.js,c:/Users/keatk/.vscode/extensions/angular.ng-template-0.1000.0-rc.1/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 63 [8:0:58.891] Loading @angular/language-service from c:\Users\keatk.vscode\extensions\angular.ng-template-0.1000.0-rc.1\server\node_modules@angular\language-service\bundles\language-service.umd.js (resolved to c:/Users/keatk/.vscode/extensions/angular.ng-template-0.1000.0-rc.1/server/node_modules/@angular/language-service/bundles/language-service.umd.js/node_modules)
Info 64 [8:0:58.904] Plugin validation succeded
Info 65 [8:0:58.910] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
Info 66 [8:0:59.911] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* Version: 1 structureChanged: true Elapsed: 1001ms
Info 67 [8:0:59.911] Project '/dev/null/inferredProject1*' (Inferred)
Info 68 [8:0:59.911] Files (100)

Info 69 [8:0:59.911] -----------------------------------------------

@ayazhafiz
Copy link
Member

Can you confirm that auto completion/go to reference isn’t working?

@keatkeat87
Copy link
Author

yup, you can clone my repository, i have update to latest
issue1

@ayazhafiz
Copy link
Member

Interesting, I guess the files from project references aren't properly passed up to the solution-style tsconfig, which takes ownership for the project. Fixing this needs some more investigation. In the meantime, a workaround is to comment out files: [] in the main tsconfig.json.

cc @kyliau

@ayazhafiz
Copy link
Member

Kind of surprised this wasn't reported earlier

kyliau pushed a commit to kyliau/vscode-ng-language-service that referenced this issue Jun 22, 2020
typescript 3.9.5 contains latest bug fixes. Upgrading to latest before
investigating angular#824
kyliau pushed a commit to kyliau/vscode-ng-language-service that referenced this issue Jun 22, 2020
typescript 3.9.5 contains latest bug fixes. Upgrading to latest before
investigating angular#824
ayazhafiz pushed a commit that referenced this issue Jun 22, 2020
typescript 3.9.5 contains latest bug fixes. Upgrading to latest before
investigating #824
@keatkeat87
Copy link
Author

keatkeat87 commented Jun 23, 2020

after i try the working around, comment out files: []
other error come out.
image
and
image

@andrius-pra
Copy link
Collaborator

@kyliau, getDefaultProjectForScriptInfo method attaches external file to the wrong project when using the solution-style tsconfig. It attaches app.component.html file to tsconfig.json instead of tsconfig.app.json project

It works as expected when the language service plugin has GetExternalFiles() implementation.

@kyliau
Copy link
Contributor

kyliau commented Jun 23, 2020

@andrius-pra thank you for the investigation. Yes, I can confirm your finding.

The problem here is that given an Angular template (.html) file, language service relies on the closest ancestor tsconfig.json to determine the Project it belongs to.
It works well before solution-style tsconfig was introduced, and is generally more performant because it reduces overhead in the language service without querying getExternalFiles() on every ts.Program update.
With solution-style tsconfig, the root tsconfig.json on its own does not include any files, and acts more like a "shell" of sub-projects. In this case, there is practically no way for the Angular extension to determine which sub-project the Angular template belongs to, unless the sub-project itself declares the template as external file.
It does seem to me our best bet here is to reinstate getExternalFiles().

Separately, the CLI team has received reports of slowness in IDE performance when solution-style tsconfig is used.
The issue is tracked in microsoft/TypeScript#39144
@alan-agius4 proposed that we add tsconfig.json to each application. That'd also solve this problem, with the sole exception in the case where the workspace itself is the application (root tsconfig.json is reserved for solution-style tsconfig).

@ayazhafiz
Copy link
Member

@alan-agius4 proposed that we add tsconfig.json to each application

would this be something the CLI does?

@alan-agius4
Copy link
Collaborator

@kyliau the project level tsconfig.json would still be a solution style typescript configuration file. So it won't fix the problem.

@andrius-pra, indeed this cannot be fixed by removing files: [] as this changes the sematics of the root tsconfig file from a solutions tsconfig file to a composite project tsconfig file.

@ayazhafiz, yeah the CLI would update the workspace and create the new tsconfig files.

@kyliau
Copy link
Contributor

kyliau commented Jun 24, 2020

I'll fix this in @angular/language-service v10.0.1 which will be released July 1, 2020.

@kyliau kyliau changed the title angular v10.0.0-rc.6 language service not working v0.1000.0 does not support solution-style tsconfig Jun 24, 2020
kyliau added a commit to kyliau/angular that referenced this issue Jun 25, 2020
`getExternalFiles()` is an API that could optionally be provided by a tsserver plugin
to notify the server of any additional files that should belong to a particular project.

This API was removed in angular#34260 mainly
due to performance reasons.

However, with the introduction of "solution-style" tsconfig in typescript 3.9,
the Angular extension could no longer reliably detect the owning Project solely
based on the ancestor tsconfig.json. In order to support this use case, we have
to reinstate `getExternalFiles()`.

Fixes angular/vscode-ng-language-service#824
@kyliau
Copy link
Contributor

kyliau commented Jun 25, 2020

angular/angular#37750 has been created to reinstate getExternalFiles().

For users who are interested in knowing why this fix did not get shipped in v0.1000.0, it's because we've already entered "code freeze" period in our RC release stage when this issue was filed. I apologize to anyone who tried out Angular v10 and got frustrated that the language service did not work out of the box (for new projects). Sorry for the inconvenience.

Going forward, we're going to implement tighter integration between language service and CLI, so that we could detect problems like this much sooner.

AndrewKushnir pushed a commit to angular/angular that referenced this issue Jun 26, 2020
`getExternalFiles()` is an API that could optionally be provided by a tsserver plugin
to notify the server of any additional files that should belong to a particular project.

This API was removed in #34260 mainly
due to performance reasons.

However, with the introduction of "solution-style" tsconfig in typescript 3.9,
the Angular extension could no longer reliably detect the owning Project solely
based on the ancestor tsconfig.json. In order to support this use case, we have
to reinstate `getExternalFiles()`.

Fixes angular/vscode-ng-language-service#824

PR Close #37750
@kyliau
Copy link
Contributor

kyliau commented Jun 26, 2020

Reopening this until fix gets released next week.

@kyliau
Copy link
Contributor

kyliau commented Jun 26, 2020

This has been fixed in v0.1000.1 which just got released.
https://github.com/angular/vscode-ng-language-service/releases/tag/v0.1000.1
I'll close this issue for now, please open a new issue if you run into problem with solution-style tsconfig.

@kyliau kyliau closed this as completed Jun 26, 2020
@JohnnyDevNull
Copy link

@kyliau see my comment here angular/angular#37781 (comment) . This is still not working.

@andrius-pra
Copy link
Collaborator

@JohnnyDevNull, could you provide Console output (Go to toolbar --> View --> Output, and copy the contents)?
Does it work in new project?

npm install -g @angular/cli
ng new ng10
code ng10

@JohnnyDevNull
Copy link

JohnnyDevNull commented Jun 27, 2020

@andrius-pra see my issue linked above. I've done the same proccess as described there fresh and clean. Also with fresh installed angular cli.

Edit: by the way i've also done a uninstall und re-install of the angular-cli globally

@kyliau
Copy link
Contributor

kyliau commented Jun 27, 2020

@JohnnyDevNull Could you please show the console output? It should look similar to this

Screen Shot 2020-06-27 at 7 44 03 AM

@JohnnyDevNull
Copy link

JohnnyDevNull commented Jun 27, 2020

@kyliau here it is:

image

Edit: This was a complete fresh install, also after re-installing the cli globally
Edit 2: Oh by the way i'am actually using CodeOSS because i'am on a Manjaro KDE if that matters

@kyliau
Copy link
Contributor

kyliau commented Jun 27, 2020

@JohnnyDevNull It looks like Angular LS is activated on tsconfig.app.json, but you are expecting autocomplete for library components / directives, which are presumably in another project (configured by another tsconfig.*.json)?

@JohnnyDevNull
Copy link

JohnnyDevNull commented Jun 27, 2020

@kyliau what i've done is

tldr; i think you should repoen issue angular/angular#37781 because it sill does not work

ng new ng-test --create-application=false --skipGit
ng g library my-test --prefix=mt
ng g library my-test2 --prefix=mt2
ng g application my-tester --routing=true --style=scss
ng build --project=my-test
ng build --project=my-test2

when you now import the MyTestModule into the AppModule at the my-tester App no path matching is working.
And also right out of the box the tsconfig.base.json inheritance is not working because of the decorators error.

All files are auto-generated from the cli and not modified from me!

The errors are just the same with the updated version as mentioned in my issue:

image

I've done the clean Angular-Cli setup to be sure that no of my configurations in my library project breaks something.
But this as i mentioned does not work right out of the box with the auto generated Angular Template from the cli and the schematics scaffholding.

By the way it's correct that the Angular LS loads the tsconfig.app.json. This inherits from the tsconfig.base.json and there the path matchings are configurated.

tsconfig.app.json

/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/app",
    "types": []
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}

tsconfig.base.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "module": "es2020",
    "lib": [
      "es2018",
      "dom"
    ],
    "paths": {
      "my-test": [
        "dist/my-test/my-test",
        "dist/my-test"
      ]
    }
  }
}

tsconfig.json (solution tsconfig)

/*
  This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
  It is not intended to be used to perform a compilation.

  To learn more about this file see: https://angular.io/config/solution-tsconfig.
*/
{
  "files": [],
  "references": [
    {
      "path": "./projects/my-test/tsconfig.lib.json"
    },
    {
      "path": "./projects/my-test/tsconfig.spec.json"
    },
    {
      "path": "./projects/my-tester/tsconfig.app.json"
    },
    {
      "path": "./projects/my-tester/tsconfig.spec.json"
    },
    {
      "path": "./projects/my-tester/e2e/tsconfig.json"
    }
]
}

@andrius-pra
Copy link
Collaborator

@JohnnyDevNull, Did you remove "files": [], from tsconfig.json in root directory?

I don't get any error. I did these steps:

Create workspace:

ng new ng-test --create-application=false --skipInstall --skipGit
cd ng-test
ng g library my-test --prefix=mt
ng g library my-test2 --prefix=mt2
ng g application --name my-tester --routing=false --style=css
ng build --project=my-test
ng build --project=my-test2
code . projects\my-tester\src\app\app.module.ts

add imports to app.module.ts:

import { MyTestModule } from 'my-test'
import { MyTest2Module } from 'my-test2'

console output:

[Info  - 19:08:58] Angular language server process ID: 24660
[Info  - 19:08:58] Using typescript v3.9.5 from c:\Users\Andrius\.vscode\extensions\angular.ng-template-0.1000.1\node_modules\typescript\lib\tsserverlibrary.js
[Info  - 19:08:58] Using @angular/language-service v10.0.1 from c:\Users\Andrius\.vscode\extensions\angular.ng-template-0.1000.1\server\node_modules\@angular\language-service\bundles\language-service.umd.js
[Info  - 19:08:58] Log file: c:\Users\Andrius\AppData\Roaming\Code\logs\20200627T190857\exthost3\Angular.ng-template\nglangsvc.log
[Info  - 19:09:02] Disabling language service for d:/a/ng-test/tsconfig.json because it is not an Angular project ('@angular/core/core.d.ts' could not be found). If you believe you are seeing this message in error, please reinstall the packages in your package.json.
[Info  - 19:09:02] Enabling language service for d:/a/ng-test/projects/my-test/tsconfig.lib.json.
[Info  - 19:09:02] Enabling language service for d:/a/ng-test/projects/my-test/tsconfig.spec.json.
[Info  - 19:09:02] Enabling language service for d:/a/ng-test/projects/my-test2/tsconfig.lib.json.
[Info  - 19:09:02] Enabling language service for d:/a/ng-test/projects/my-test2/tsconfig.spec.json.
[Info  - 19:09:02] Enabling language service for d:/a/ng-test/projects/my-tester/tsconfig.app.json.

@JohnnyDevNull
Copy link

JohnnyDevNull commented Jun 27, 2020

@andrius-pra

#824 (comment)

All files are auto-generated from the cli and not modified from me!

@alan-agius4
Copy link
Collaborator

Note: please don’t remove "files": [] this changes the sematics and meaning of the root tsconfig. When remove the empty array you are opting out of solutions style tsconfig.

Removing this, will cause undefined behaviour, and by no means is supported.

I think what you are experiencing sound similar to angular/angular-cli#16708

Does this same issue persists when restarting the LS?

@JohnnyDevNull
Copy link

JohnnyDevNull commented Jun 27, 2020

I think i have found the problem for VSCode:

VSCode (Or in my case Code OSS) uses per default the shipped Version TypeScript 3.8.3 by now which does not support solution config with inheritance.

I've put that into settings.json, so that the workspace version is used

{
  "typescript.tsdk": "node_modules/typescript/lib"
}

My output still is the same, but the errors are gone:

image

@alan-agius4
Copy link
Collaborator

@JohnnyDevNull, indeed you need to make sure that you force VSCode to use the project level TypeScript package.

@freed00m
Copy link

freed00m commented Jun 29, 2020

@alan-agius4 are you sure it fixed the problem? I am on latest stable of Everything I could've updated. Dependencies and vscode +plugins and the issue persist, even with version 10.0.1, when the mentioned files: [] is at root tsconfig.json, the VScode wont autocomplete anything.

EDIT: it's working, it's just I had more than one tsconfig (tsconfig.app.json and tsconfig.demo.json) and had multiple exclude scenarios, now VScode refuses to import modules in the excluded files, which I think is wrong.

Example, I exclude all files in the tsconfig.app.json under path src/app/demo/** but it's not excluded in the tsconfig.demo.json (because I have more build targets) and VScode will never offer me help in the src/app/demo/**, I am currently thinking about how to solve this.

Another thing, the important stuff is the include: [] at tsconfig.app.json, the angular 10 now defautls to value *.d.ts compared to *.ts prior causing VScode to not traverse many files if *.d.ts is left there or include array completely ommited. In either scenario, the compilation always succeeds just VScode plugins have troubles.

@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 Jul 31, 2020
profanis pushed a commit to profanis/angular that referenced this issue Sep 5, 2020
`getExternalFiles()` is an API that could optionally be provided by a tsserver plugin
to notify the server of any additional files that should belong to a particular project.

This API was removed in angular#34260 mainly
due to performance reasons.

However, with the introduction of "solution-style" tsconfig in typescript 3.9,
the Angular extension could no longer reliably detect the owning Project solely
based on the ancestor tsconfig.json. In order to support this use case, we have
to reinstate `getExternalFiles()`.

Fixes angular/vscode-ng-language-service#824

PR Close angular#37750
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants