From 78236bfdcaeb66c5846eb0435d727942bb88f7c5 Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Wed, 7 Apr 2021 11:38:47 -0400 Subject: [PATCH] fix(language-service): use script versions for incremental compilations (#41475) This commit has the Language Service take advantage of versioned source files added in the compiler previously. With this change, the Language Service's incremental compilations will now be correct even if the TS Language service mutates `ts.SourceFile`s without changing their object identity, as we know it does in certain corner cases. No test is added here as it is difficult to reproduce this behavior in the LS's artificial testing environment. A test for this case exists in the LS extension repo, where it will be used to validate that a workaround three is no longer necessary. PR Close #41475 --- packages/language-service/ivy/language_service.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/language-service/ivy/language_service.ts b/packages/language-service/ivy/language_service.ts index 23d1c7e07e..ec6c18a09a 100644 --- a/packages/language-service/ivy/language_service.ts +++ b/packages/language-service/ivy/language_service.ts @@ -487,6 +487,9 @@ function createProgramDriver(project: ts.server.Project): ProgramDriver { scriptInfo.editContent(0, length, newText); } }, + getSourceFileVersion(sf: ts.SourceFile): string { + return project.getScriptVersion(sf.fileName); + } }; }