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

Support project references / solution-style configs (common in Nx projects) #876

Closed
smlombardi opened this issue Jul 31, 2020 · 20 comments
Closed

Comments

@smlombardi
Copy link

smlombardi commented Jul 31, 2020

Issue Type: Bug

Recently, I can no longer get suggestions of Angular HTML attributes and variable suggestions. Also, it no longer shows errors as it used to such as when I bound to a non-existant variable. So basically I have no Angular support in my HTML templates any longer.

Extension version: 0.1000.7
VS Code version: Code - Insiders 1.48.0-insider (c9a2f78283b6e5ef708fb8869e2a5adaa476e42f, 2020-07-31T07:35:12.881Z)
OS version: Darwin x64 19.6.0

Angular CLI: 10.0.4
Node: 12.18.1
OS: darwin x64

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

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.4
@angular-devkit/build-angular     0.1000.4
@angular-devkit/build-optimizer   0.1000.4
@angular-devkit/build-webpack     0.1000.4
@angular-devkit/core              10.0.4
@angular-devkit/schematics        10.0.4
@angular/cdk                      10.1.1
@angular/cli                      10.0.4
@angular/material                 10.1.1
@ngtools/webpack                  10.0.4
@schematics/angular               10.0.4
@schematics/update                0.1000.4
rxjs                              6.6.0
typescript                        3.9.7
webpack                           4.43.0
System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) 18, 6, 4
Memory (System) 16.00GB (0.01GB free)
Process Argv -psn_0_2732699
Screen Reader no
VM 0%
@pstarostka-zz
Copy link

I have the same problem when using Nx workspace layout. I get no intellisense in any lib.

@kyliau
Copy link
Contributor

kyliau commented Jul 31, 2020

Please show us two logs:

  1. In vscode, go to Output -> Angular language service
  2. From the same output, find the log file, and paste the content here

@kyliau kyliau changed the title Template intellisense and error checking stopped working Template intellisense and error checking stopped working in vscode insider Jul 31, 2020
@smlombardi
Copy link
Author

smlombardi commented Jul 31, 2020

[Info  - 11:19:22 AM] Angular language server process ID: 83468
[Info  - 11:19:22 AM] Using typescript/lib/tsserverlibrary v3.9.5 from /Users/steve/.vscode-insiders/extensions/angular.ng-template-0.1000.7/node_modules/typescript/lib/tsserverlibrary.js
[Info  - 11:19:22 AM] Using @angular/language-service v10.0.7 from /Users/steve/.vscode-insiders/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js
[Info  - 11:19:22 AM] Log file: /Users/steve/Library/Application Support/Code - Insiders/logs/20200731T070413/exthost8/Angular.ng-template/nglangsvc.log
[Info  - 11:19:32 AM] Enabling language service for /Users/steve/github/myproject/libs/sending/tsconfig.json.
Info 0    [11:19:21.306] Format host information updated
Info 1    [11:19:21.309] reload projects.
Info 2    [11:19:21.310] Before ensureProjectForOpenFiles:
Info 3    [11:19:21.310] After ensureProjectForOpenFiles:
Info 4    [11:19:21.310] Host file extension mappings updated
Info 5    [11:19:22.345] Search path: /Users/steve/github/myproject/libs/sending/src/lib/shared/weight-input
Info 6    [11:19:22.346] For info: /Users/steve/github/myproject/libs/sending/src/lib/shared/weight-input/weight-input.component.ts :: Config file name: /Users/steve/github/myproject/libs/sending/tsconfig.json
Info 7    [11:19:22.346] Opened configuration file /Users/steve/github/myproject/libs/sending/tsconfig.json
Info 8    [11:19:22.757] Config: /Users/steve/github/myproject/libs/sending/tsconfig.json : {
 "rootNames": [
  "/Users/steve/github/myproject/libs/sending/src/index.ts",
  "/Users/steve/github/myproject/libs/sending/src/test-setup.ts",
  ...etc...
 ],
 "options": {
  "rootDir": "/Users/steve/github/myproject",
  "sourceMap": true,
  "declaration": false,
  "moduleResolution": 2,
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "importHelpers": true,
  "target": 2,
  "module": 99,
  "typeRoots": [
   "/Users/steve/github/myproject/node_modules/@types"
  ],
  "lib": [
   "lib.es2017.d.ts",
   "lib.dom.d.ts"
  ],
  "skipLibCheck": true,
  "skipDefaultLibCheck": true,
  "baseUrl": "/Users/steve/github/myproject",
  "paths": {
   "@spa/sending": [
    "libs/sending/src/index.ts"
   ],
   "@spa/receiving": [
    "libs/receiving/src/index.ts"
   ],
   "@spa/lockers": [
    "libs/lockers/src/index.ts"
   ],
   "@spa/analytics": [
    "libs/analytics/src/index.ts"
   ],
   "@spa/shared": [
    "libs/shared/src/index.ts"
   ],
   "@spa/auth": [
    "libs/auth/src/index.ts"
   ],
   "@spa/home": [
    "libs/home/src/index.ts"
   ],
   "@spa/settings": [
    "libs/settings/src/index.ts"
   ],
   "@spa/address": [
    "libs/address/src/index.ts"
   ],
   "@spa/remote": [
    "libs/remote/src/index.ts"
   ],
   "@spa/animations": [
    "libs/animations/src/index.ts"
   ],
   "@spa/shared-services": [
    "libs/shared-services/src/index.ts"
   ],
   "@spa/user": [
    "libs/user/src/index.ts"
   ],
   "@spa/error": [
    "libs/error/src/index.ts"
   ],
   "@spa/admin": [
    "libs/admin/src/index.ts"
   ],
   "@spa/layout": [
    "libs/layout/src/index.ts"
   ],
   "@spa/cost-accounts": [
    "libs/cost-accounts/src/index.ts"
   ],
   "@spa/about": [
    "libs/about/src/index.ts"
   ]
  },
  "types": [
   "node",
   "jest"
  ],
  "configFilePath": "/Users/steve/github/myproject/libs/sending/tsconfig.json"
 }
}
Info 9    [11:19:22.762] Loading global plugin @angular/language-service
Info 10   [11:19:22.763] Enabling plugin @angular/language-service from candidate paths: /Users/steve/.vscode-insiders/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js,/Users/steve/.vscode-insiders/extensions/angular.ng-template-0.1000.7/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 11   [11:19:22.763] Loading @angular/language-service from /Users/steve/.vscode-insiders/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js (resolved to /Users/steve/.vscode-insiders/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js/node_modules)
Info 12   [11:19:22.958] Plugin validation succeded
Info 13   [11:19:23.23] Starting updateGraphWorker: Project: /Users/steve/github/myproject/libs/sending/tsconfig.json
Info 14   [11:19:32.49] Finishing updateGraphWorker: Project: /Users/steve/github/myproject/libs/sending/tsconfig.json Version: 1 structureChanged: true Elapsed: 9026ms
Info 15   [11:19:32.49] Project '/Users/steve/github/myproject/libs/sending/tsconfig.json' (Configured)
Info 16   [11:19:32.49] 	Files (1056)

Info 17   [11:19:32.49] -----------------------------------------------
Info 18   [11:19:32.59] Starting updateGraphWorker: Project: /Users/steve/github/myproject/libs/sending/tsconfig.json
Info 19   [11:19:32.70] Finishing updateGraphWorker: Project: /Users/steve/github/myproject/libs/sending/tsconfig.json Version: 2 structureChanged: false Elapsed: 11ms

@smlombardi
Copy link
Author

smlombardi commented Jul 31, 2020

I have the same problem when using Nx workspace layout. I get no intellisense in any lib.

That's what I am using also. It did work, as recently as last week. It seems vscode has issues with nx workspaces using a tsconfig.base.json and having each lib's tsconfig.json point to it.

@kyliau
Copy link
Contributor

kyliau commented Jul 31, 2020

Does this happen if you use the stable version of vscode?

@drullo
Copy link

drullo commented Jul 31, 2020

I seem to be having the same (or similar) issue. No intellisense and the editor thinks that components from my library don't exist. However, they do work. If I disable or remove the Language Service extension, the editor warning goes away - but obviously still no intellisense.

@smlombardi
Copy link
Author

Does not work in non-insiders VSCode, but I get different output:

[Info  - 5:36:26 PM] Log file: /Users/steve/Library/Application Support/Code/logs/20200731T173031/exthost1/Angular.ng-template/nglangsvc.log
[Info  - 5:36:30 PM] Disabling language service for /Users/steve/github/myproject/libs/print/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  - 5:36:30 PM] Disabling language service for /Users/steve/github/myproject/libs/print/tsconfig.lib.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  - 5:36:30 PM] Enabling language service for /Users/steve/github/myproject/libs/print/tsconfig.spec.json.
[Error - 5:36:30 PM] No config file for /Users/steve/github/myproject/libs/print/src/lib/page-home/page-home.component.html
Info 0    [17:36:26.992] Format host information updated
Info 1    [17:36:26.992] reload projects.
Info 2    [17:36:26.992] Before ensureProjectForOpenFiles:
Info 3    [17:36:26.993] After ensureProjectForOpenFiles:
Info 4    [17:36:26.993] Host file extension mappings updated
Info 5    [17:36:27.6] Search path: /Users/steve/github/myproject/libs/print/src/lib/page-home
Info 6    [17:36:27.13] For info: /Users/steve/github/myproject/libs/print/src/lib/page-home/page-home.component.html :: Config file name: /Users/steve/github/myproject/libs/print/tsconfig.json
Info 7    [17:36:27.14] Opened configuration file /Users/steve/github/myproject/libs/print/tsconfig.json
Info 8    [17:36:27.38] Config: /Users/steve/github/myproject/libs/print/tsconfig.json : {
 "rootNames": [],
 "options": {
  "rootDir": "/Users/steve/github/myproject",
  "sourceMap": true,
  "declaration": false,
  "moduleResolution": 2,
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "importHelpers": true,
  "target": 2,
  "module": 99,
  "typeRoots": [
   "/Users/steve/github/myproject/node_modules/@types"
  ],
  "lib": [
   "lib.es2017.d.ts",
   "lib.dom.d.ts"
  ],
  "skipLibCheck": true,
  "skipDefaultLibCheck": true,
  "baseUrl": "/Users/steve/github/myproject",
  "paths": {
   "@spg/auth": [
    "libs/auth/src/index.ts"
   ],
   "@spg/shared": [
    "libs/shared/src/index.ts"
   ],
   "@spg/address": [
    "libs/address/src/index.ts"
   ],
   "@spg/print": [
    "libs/print/src/index.ts"
   ],
   "@spg/settings": [
    "libs/settings/src/index.ts"
   ],
   "@spg/layout": [
    "libs/layout/src/index.ts"
   ],
   "@spg/user": [
    "libs/user/src/index.ts"
   ],
   "@spg/error": [
    "libs/error/src/index.ts"
   ],
   "@spg/remote": [
    "libs/remote/src/index.ts"
   ],
   "@spg/dashboard": [
    "libs/dashboard/src/index.ts"
   ],
   "@spg/history": [
    "libs/history/src/index.ts"
   ],
   "@spg/orders": [
    "libs/orders/src/index.ts"
   ],
   "@spg/shared-services": [
    "libs/shared-services/src/index.ts"
   ],
   "@spg/animations": [
    "libs/animations/src/index.ts"
   ]
  },
  "configFilePath": "/Users/steve/github/myproject/libs/print/tsconfig.json"
 },
 "projectReferences": [
  {
   "path": "/Users/steve/github/myproject/libs/print/tsconfig.lib.json",
   "originalPath": "./tsconfig.lib.json"
  },
  {
   "path": "/Users/steve/github/myproject/libs/print/tsconfig.spec.json",
   "originalPath": "./tsconfig.spec.json"
  }
 ]
}
Info 9    [17:36:27.39] Loading global plugin @angular/language-service
Info 10   [17:36:27.39] Enabling plugin @angular/language-service from candidate paths: /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js,/Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 11   [17:36:27.39] Loading @angular/language-service from /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js (resolved to /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js/node_modules)
Info 12   [17:36:27.127] Plugin validation succeded
Info 13   [17:36:27.203] Starting updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.json
Info 14   [17:36:27.233] Finishing updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.json Version: 1 structureChanged: true Elapsed: 30ms
Info 15   [17:36:27.233] Project '/Users/steve/github/myproject/libs/print/tsconfig.json' (Configured)
Info 16   [17:36:27.233] 	Files (0)

Info 17   [17:36:27.233] -----------------------------------------------
Info 18   [17:36:27.234] Starting updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.json
Info 19   [17:36:27.234] Finishing updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.json Version: 2 structureChanged: false Elapsed: 0ms
Info 20   [17:36:27.236] Disabling language service for /Users/steve/github/myproject/libs/print/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   [17:36:27.236] Opened configuration file /Users/steve/github/myproject/libs/print/tsconfig.lib.json
Info 22   [17:36:27.238] Config: /Users/steve/github/myproject/libs/print/tsconfig.lib.json : {
 "rootNames": [],
 "options": {
  "rootDir": "/Users/steve/github/myproject",
  "sourceMap": true,
  "declaration": true,
  "moduleResolution": 2,
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "importHelpers": true,
  "target": 2,
  "module": 99,
  "typeRoots": [
   "/Users/steve/github/myproject/node_modules/@types"
  ],
  "lib": [
   "lib.dom.d.ts",
   "lib.es2018.d.ts"
  ],
  "skipLibCheck": true,
  "skipDefaultLibCheck": true,
  "baseUrl": "/Users/steve/github/myproject",
  "paths": {
   "@spg/auth": [
    "libs/auth/src/index.ts"
   ],
   "@spg/shared": [
    "libs/shared/src/index.ts"
   ],
   "@spg/address": [
    "libs/address/src/index.ts"
   ],
   "@spg/print": [
    "libs/print/src/index.ts"
   ],
   "@spg/settings": [
    "libs/settings/src/index.ts"
   ],
   "@spg/layout": [
    "libs/layout/src/index.ts"
   ],
   "@spg/user": [
    "libs/user/src/index.ts"
   ],
   "@spg/error": [
    "libs/error/src/index.ts"
   ],
   "@spg/remote": [
    "libs/remote/src/index.ts"
   ],
   "@spg/dashboard": [
    "libs/dashboard/src/index.ts"
   ],
   "@spg/history": [
    "libs/history/src/index.ts"
   ],
   "@spg/orders": [
    "libs/orders/src/index.ts"
   ],
   "@spg/shared-services": [
    "libs/shared-services/src/index.ts"
   ],
   "@spg/animations": [
    "libs/animations/src/index.ts"
   ]
  },
  "outDir": "/Users/steve/github/myproject/dist/out-tsc",
  "inlineSources": true,
  "types": [],
  "configFilePath": "/Users/steve/github/myproject/libs/print/tsconfig.lib.json"
 }
}
Info 23   [17:36:27.238] Loading global plugin @angular/language-service
Info 24   [17:36:27.238] Enabling plugin @angular/language-service from candidate paths: /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js,/Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 25   [17:36:27.238] Loading @angular/language-service from /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js (resolved to /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js/node_modules)
Info 26   [17:36:27.245] Plugin validation succeded
Info 27   [17:36:27.245] Starting updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.lib.json
Info 28   [17:36:27.247] Finishing updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.lib.json Version: 1 structureChanged: true Elapsed: 2ms
Info 29   [17:36:27.247] Different program with same set of files:: oldProgram.structureIsReused:: undefined
Info 30   [17:36:27.247] Starting updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.lib.json
Info 31   [17:36:27.247] Finishing updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.lib.json Version: 2 structureChanged: false Elapsed: 0ms
Info 32   [17:36:27.247] Disabling language service for /Users/steve/github/myproject/libs/print/tsconfig.lib.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 33   [17:36:27.247] Opened configuration file /Users/steve/github/myproject/libs/print/tsconfig.spec.json
Info 34   [17:36:27.258] Config: /Users/steve/github/myproject/libs/print/tsconfig.spec.json : {
 "rootNames": [
  "/Users/steve/github/myproject/libs/print/src/test-setup.ts",
  "/Users/steve/github/myproject/libs/print/src/lib/page-home/page-home.component.spec.ts"
 ],
 "options": {
  "rootDir": "/Users/steve/github/myproject",
  "sourceMap": true,
  "declaration": false,
  "moduleResolution": 2,
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "importHelpers": true,
  "target": 2,
  "module": 1,
  "typeRoots": [
   "/Users/steve/github/myproject/node_modules/@types"
  ],
  "lib": [
   "lib.es2017.d.ts",
   "lib.dom.d.ts"
  ],
  "skipLibCheck": true,
  "skipDefaultLibCheck": true,
  "baseUrl": "/Users/steve/github/myproject",
  "paths": {
   "@spg/auth": [
    "libs/auth/src/index.ts"
   ],
   "@spg/shared": [
    "libs/shared/src/index.ts"
   ],
   "@spg/address": [
    "libs/address/src/index.ts"
   ],
   "@spg/print": [
    "libs/print/src/index.ts"
   ],
   "@spg/settings": [
    "libs/settings/src/index.ts"
   ],
   "@spg/layout": [
    "libs/layout/src/index.ts"
   ],
   "@spg/user": [
    "libs/user/src/index.ts"
   ],
   "@spg/error": [
    "libs/error/src/index.ts"
   ],
   "@spg/remote": [
    "libs/remote/src/index.ts"
   ],
   "@spg/dashboard": [
    "libs/dashboard/src/index.ts"
   ],
   "@spg/history": [
    "libs/history/src/index.ts"
   ],
   "@spg/orders": [
    "libs/orders/src/index.ts"
   ],
   "@spg/shared-services": [
    "libs/shared-services/src/index.ts"
   ],
   "@spg/animations": [
    "libs/animations/src/index.ts"
   ]
  },
  "outDir": "/Users/steve/github/myproject/dist/out-tsc",
  "types": [
   "jest",
   "node"
  ],
  "configFilePath": "/Users/steve/github/myproject/libs/print/tsconfig.spec.json"
 }
}
Info 35   [17:36:27.258] Loading global plugin @angular/language-service
Info 36   [17:36:27.258] Enabling plugin @angular/language-service from candidate paths: /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js,/Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 37   [17:36:27.258] Loading @angular/language-service from /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js (resolved to /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js/node_modules)
Info 38   [17:36:27.267] Plugin validation succeded
Info 39   [17:36:27.268] Starting updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.spec.json
Info 40   [17:36:29.861] Finishing updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.spec.json Version: 1 structureChanged: true Elapsed: 2593ms
Info 41   [17:36:29.861] Project '/Users/steve/github/myproject/libs/print/tsconfig.spec.json' (Configured)
Info 42   [17:36:29.861] 	Files (391)

Info 43   [17:36:29.861] -----------------------------------------------
Info 44   [17:36:29.862] Starting updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.spec.json
Info 45   [17:36:29.865] Finishing updateGraphWorker: Project: /Users/steve/github/myproject/libs/print/tsconfig.spec.json Version: 2 structureChanged: false Elapsed: 3ms
Info 46   [17:36:29.868] Loading global plugin @angular/language-service
Info 47   [17:36:29.868] Enabling plugin @angular/language-service from candidate paths: /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js,/Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/node_modules/typescript/lib/tsserverlibrary.js/../../..
Info 48   [17:36:29.868] Loading @angular/language-service from /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js (resolved to /Users/steve/.vscode/extensions/angular.ng-template-0.1000.7/server/node_modules/@angular/language-service/bundles/language-service.js/node_modules)
Info 49   [17:36:29.874] Plugin validation succeded
Info 50   [17:36:29.876] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
Info 51   [17:36:30.811] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* Version: 1 structureChanged: true Elapsed: 935ms
Info 52   [17:36:30.811] Project '/dev/null/inferredProject1*' (Inferred)
Info 53   [17:36:30.811] 	Files (134)

Info 54   [17:36:30.811] -----------------------------------------------
Info 55   [17:36:34.613] Search path: /Users/steve/github/myproject/libs/print/src/lib/page-home
Info 56   [17:36:34.613] For info: /Users/steve/github/myproject/libs/print/src/lib/page-home/page-home.component.html :: Config file name: /Users/steve/github/myproject/libs/print/tsconfig.json

@smlombardi
Copy link
Author

smlombardi commented Jul 31, 2020

Each nxjs /lib directory has its own tsconfig.json like this

{
  "extends": "../../tsconfig.base.json",
  "files": [],
  "include": [],
  "references": [
    {
      "path": "./tsconfig.lib.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
  ]
}

and the tsconfig.base.json they all point to is this:

{
  "compileOnSave": false,
  "compilerOptions": {
    "rootDir": ".",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "module": "esnext",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom"],
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "baseUrl": ".",
    "paths": {
      "@spg/auth": ["libs/auth/src/index.ts"],
      "@spg/shared": ["libs/shared/src/index.ts"],
      "@spg/address": ["libs/address/src/index.ts"],
      "@spg/print": ["libs/print/src/index.ts"],
      "@spg/settings": ["libs/settings/src/index.ts"],
      "@spg/layout": ["libs/layout/src/index.ts"],
      "@spg/user": ["libs/user/src/index.ts"],
      "@spg/error": ["libs/error/src/index.ts"],
      "@spg/remote": ["libs/remote/src/index.ts"],
      "@spg/dashboard": ["libs/dashboard/src/index.ts"],
      "@spg/history": ["libs/history/src/index.ts"],
      "@spg/orders": ["libs/orders/src/index.ts"],
      "@spg/shared-services": ["libs/shared-services/src/index.ts"],
      "@spg/animations": ["libs/animations/src/index.ts"]
    }
  },
  "exclude": ["node_modules", "tmp"]
}

@smlombardi
Copy link
Author

It would seem this is an issue with Angular 10 using tsconfig.base.json file. I am finding many issues on VSCode and Webstorm related to this.

@pstarostka-zz
Copy link

I think I found a workaround of sorts...
In the lib, change tsconfig.json from something like this:

{
  "extends": "../../tsconfig.base.json",
  "files": [],
  "include": [],
  "references": [
    {
      "path": "./tsconfig.lib.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
  ],
}

to something like this:

{
  "extends": "../../tsconfig.base.json"
}

tsconfig.lib.json and tsconfig.spec.json for the lib should extend the tsconfig.json you modified - so basically no changes there

Here's my tsconfig.lib.json for reference:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc",
    "target": "es2015",
    "declaration": true,
    "inlineSources": true,
    "types": [],
    "lib": ["dom", "es2018"]
  },

  "exclude": ["src/test-setup.ts", "**/*.spec.ts"]
}

Hope this helps!

@kyliau kyliau changed the title Template intellisense and error checking stopped working in vscode insider Support project references Nov 13, 2020
@kpaxton
Copy link

kpaxton commented May 4, 2021

I'm having this same issue with an NX 12 workspace and Angular 11.2+. The Language service does not pick up configured paths in the tsconfig.base.json.
NX is aware of the issue and doesn't believe they have the ability to fix this problem. nrwl/nx#3342

Is there something that the language service can be given a glob or file pointer to include for suggestions?

@frontendbuddy
Copy link

Hey a little hint for everyone who uses the include to eg. include some additional files. TypeScript handles this option in more or less this way: If you don't have it set then it will default to as it would exist with value of ["**/*"] (so it will include everything) but if you add something to that include array then you will only get that thing instead of everything + your thing.

This starts to be problematic for the Angular Language Service because as far as I understand the source code of it it's core functions base on ProjectService from tsserverlibrary which under the hood uses few things which long story short are handling the include property as it is defined in the tsconfig so without concatenating whatever you added there with default value and therefore you can get an error of "No config file for (your filename here)" when you check the Output tab in Code.

Solution seems to be very simple: your include should contain ["**/*"] aside of other things you need to put there.

Example:

{
    "extends": "./node_modules/some-dep/tsconfig.json",
    "include": [
        "**/*",
        "./node_modules/some-dep/core/@types/*"
    ]
}

@wSedlacek
Copy link

Okay so I was troubleshooting pipes, directives and components showing up as undeclared after I opened up certain files.
I believe I have tracked down the edge case I was encounter, it seems to happen when I configure the lib property within a tsconfig.lib.json or a tsconfig.app.json or any other project specific config instead of tsconfig.base.json.

I was doing this because I use NativeScript and I prefer not to have a bunch of DOM types that don't exist at runtime.
So I would configure my libs to not rely on lib dom and then my NativeScript apps would have NativeScript specific global typings and my web projects would be the only ones that used lib dom.

So it's not much of a workaround as I can't configure the types how I would like, but I was able to get the language server to not give me errors anymore by not configuring the lib on any angular projects (I can still configure them for node projects)

If this really is the issue (or at least one of them) perhaps it could be fixed soon? Let me know if you'd like a recreation.

@atscott
Copy link
Collaborator

atscott commented Mar 29, 2022

I just created a new pre-release version of the language service that adds the option to disable ngcc manually. That step has been problematic for many developers. You can download the release here: https://github.com/angular/vscode-ng-language-service/releases/tag/v14.0.0-next.0. Note that disabling ngcc will mean that you it will likely need to be run outside of the extension, though this is done during the build step anyways so if you're running a dev server while you're coding, you likely won't have to worry about this.

For those experiencing this issue, can you check if disabling ngcc in the extension options resolves the problem?

@atscott
Copy link
Collaborator

atscott commented Apr 4, 2022

Closing as fixed by fbc9e2b. See #876 (comment)

@atscott atscott closed this as completed Apr 4, 2022
@atscott atscott changed the title Support project references Support project references / solution-style configs (common in Nx projects) Apr 6, 2022
@atscott
Copy link
Collaborator

atscott commented Apr 6, 2022

Re-opening as I think there can and should be further work done here.

@atscott
Copy link
Collaborator

atscott commented Apr 6, 2022

Additional reproductions in #1616 (comment) and #1581 (comment)

@atscott
Copy link
Collaborator

atscott commented Apr 7, 2022

When opening a file, TypeScript looks for the project which references the file directly (see https://sourcegraph.com/github.com/microsoft/TypeScript@4d2fb5407c4e9999dd108972290fc57d3dd56e71/-/blob/src/server/editorServices.ts?L3353-3390) for the purposes of providing diagnostics. I haven't been able to confirm how this works with other commands/actions (go to definition/quick info/ etc). I'm also not sure how exactly this would work with angular template files since tsconfigs do not express inclusion/exclusion of non-ts files.

@atscott
Copy link
Collaborator

atscott commented Apr 7, 2022

I also suspect much of the recent instability has been due to the regression of #1438 (reopened as #1623).

#1447 ensured that language services get enabled in the order they're defined in the tsconfig references. In nx workspaces, this is generally the tsconfig.app.json which would contain the main entry point and therefore all of the files in the project through the import graph. While this might not be the one TypeScript would have chosen (tsconfig.editor.json is the one that references most files directly via **/*.ts), it should still be fine (though this likely means double the work since both project's compilations would need to be kept up to date).

Because projects are no longer kept open (again, the regression of #1438) the strategy in #1447 is breaking down.

atscott added a commit to atscott/vscode-ng-language-service that referenced this issue Apr 8, 2022
…open

VSCode/TSServer implements an optimization to close projects which no
longer have any open files in the editor (see `cleanUpAfterOpeningFile`
in TypeScript's `ProjectService`). This optimization currently results
in closing projects when only a template file is open because the
template files are not sufficiently tracked (since they're non-TS
files).

A previous attempt to fix this issue was implemented in angular#1461 but does
not work for solution-style `tsconfig` projects because when creating
the external project, it only counts towards the
`externalProjectRefCount` if the name of the tsconfig is `tsconfig.json`
or `jsconfig.json` (See call to `getBaseConfigFileName` in
`openExternalProjects`).

Instead, this fix adds the template files to the project's `rootFiles`.
This is sufficient to ensure the `hasOpenRef` check passes and the
template's project is retained when navigating to a file that exists in
a different project.

Fixes angular#1623
Fixes angular#876
atscott added a commit to atscott/vscode-ng-language-service that referenced this issue Apr 12, 2022
…service features

The implementation of the ngcc queue for re-enabling project language
service's is incorrect. It unconditionally removes projects from the
queue when the ngcc process finishes even if it finished out of order
and is waiting for the first project in the queue to finish. This
results in later projects never getting the language service re-enabled
when the earlier project(s) finally finish ngcc.

This fix works towards stabilizing the extension for solution-style projects.

Related to angular#876
atscott added a commit to atscott/angular that referenced this issue Apr 12, 2022
…d projects

When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876
atscott added a commit to atscott/angular that referenced this issue Apr 12, 2022
…d projects

When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876
atscott added a commit to atscott/angular that referenced this issue Apr 12, 2022
…d projects

When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876
atscott added a commit that referenced this issue Apr 14, 2022
…service features (#1627)

The implementation of the ngcc queue for re-enabling project language
service's is incorrect. It unconditionally removes projects from the
queue when the ngcc process finishes even if it finished out of order
and is waiting for the first project in the queue to finish. This
results in later projects never getting the language service re-enabled
when the earlier project(s) finally finish ngcc.

This fix works towards stabilizing the extension for solution-style projects.

Related to #876
atscott added a commit that referenced this issue Apr 14, 2022
…service features (#1627)

The implementation of the ngcc queue for re-enabling project language
service's is incorrect. It unconditionally removes projects from the
queue when the ngcc process finishes even if it finished out of order
and is waiting for the first project in the queue to finish. This
results in later projects never getting the language service re-enabled
when the earlier project(s) finally finish ngcc.

This fix works towards stabilizing the extension for solution-style projects.

Related to #876

(cherry picked from commit 5712ab8)
atscott added a commit to atscott/angular that referenced this issue Apr 15, 2022
…d projects

When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876
atscott added a commit to atscott/angular that referenced this issue Apr 19, 2022
…d projects

When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876
atscott added a commit to atscott/angular that referenced this issue Apr 22, 2022
…d projects

When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876
atscott added a commit to atscott/angular that referenced this issue May 10, 2022
…d projects

When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876
atscott added a commit to atscott/angular that referenced this issue May 10, 2022
…d projects

When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876
AndrewKushnir pushed a commit to angular/angular that referenced this issue May 10, 2022
…d projects (#45601)

When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876

PR Close #45601
AndrewKushnir pushed a commit to angular/angular that referenced this issue May 10, 2022
…d projects (#45601)

When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876

PR Close #45601
@atscott atscott reopened this May 11, 2022
@atscott atscott closed this as completed May 12, 2022
@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 Jun 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants