From dd049caf0a261c4a1c779e1567cbcfc7f0fdc3e1 Mon Sep 17 00:00:00 2001 From: ivanwonder Date: Fri, 24 Apr 2020 10:45:31 +0800 Subject: [PATCH] fix(language-service): disable update the `@angular/core` module (#36783) After the user edits the file `core.d.ts`, the symbol from the core module will be invalided, which only is created when init the language service. Then the language-service will crash. PR Close #36783 --- packages/language-service/src/typescript_host.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/language-service/src/typescript_host.ts b/packages/language-service/src/typescript_host.ts index 836b8cc956..324f9d1a6b 100644 --- a/packages/language-service/src/typescript_host.ts +++ b/packages/language-service/src/typescript_host.ts @@ -217,7 +217,14 @@ export class TypeScriptServiceHost implements LanguageServiceHost { // Check if any source files have been added / changed since last computation. const seen = new Set(); + const ANGULAR_CORE = '@angular/core'; + const corePath = this.reflectorHost.moduleNameToFileName(ANGULAR_CORE); for (const {fileName} of program.getSourceFiles()) { + // If the `@angular/core` has been edited, the language service should be restart, + // so ignore the change of `@angular/core`. + if (fileName === corePath) { + continue; + } seen.add(fileName); const version = this.tsLsHost.getScriptVersion(fileName); const lastVersion = this.fileVersions.get(fileName);