From c844f43e2838c63b2e65d12f413078923cbe9089 Mon Sep 17 00:00:00 2001 From: cexbrayat Date: Wed, 26 May 2021 21:35:35 +0200 Subject: [PATCH] fix(compiler): make sure language service use updated compiler options The compiler options are updated to have the proper module kind and are used by `_transpileOutput`. But when the compilation is delegated to the language service, the updated compiler options are not used, and the module kind ends up being the one in the initially read configuration. To make sure the language service gets the updated compiler options, this commit bumps the project version, thus ensuring that the internal `synchronizeHostData` of the language service refresh the options. (see https://github.com/microsoft/TypeScript/blob/459bd1994115fc4a14f7f1a80c36affe2281f2ea/src/services/services.ts#L1278-L1287) --- src/compiler/ts-compiler.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/ts-compiler.ts b/src/compiler/ts-compiler.ts index 0543708566..337cffbc72 100644 --- a/src/compiler/ts-compiler.ts +++ b/src/compiler/ts-compiler.ts @@ -170,7 +170,8 @@ export class TsCompiler implements TsCompilerInstance { } if (this._languageService) { this._logger.debug({ fileName }, 'getCompiledOutput(): compiling using language service') - + // Make sure the language service gets the updated compiler options + this._projectVersion++ // Must set memory cache before attempting to compile this._updateMemoryCache(fileContent, fileName) const output: EmitOutput = this._languageService.getEmitOutput(fileName)