From ff4b302ae34320dfe9ef317af406f5693efc6c07 Mon Sep 17 00:00:00 2001 From: ahnpnl Date: Wed, 10 Jul 2024 02:18:29 +0200 Subject: [PATCH] fix: set `allowSyntheticDefaultImports` properly Fixes #4156 --- src/legacy/compiler/__snapshots__/ts-compiler.spec.ts.snap | 4 ++-- src/legacy/compiler/ts-compiler.ts | 1 - src/legacy/config/config-set.spec.ts | 2 -- src/legacy/config/config-set.ts | 5 ----- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/legacy/compiler/__snapshots__/ts-compiler.spec.ts.snap b/src/legacy/compiler/__snapshots__/ts-compiler.spec.ts.snap index 08d11b3d25..44eb97c2ed 100644 --- a/src/legacy/compiler/__snapshots__/ts-compiler.spec.ts.snap +++ b/src/legacy/compiler/__snapshots__/ts-compiler.spec.ts.snap @@ -18,7 +18,7 @@ exports[`TsCompiler getCompiledOutput isolatedModules false should compile codes exports[`TsCompiler getCompiledOutput isolatedModules false should compile codes with useESM {"babelConfig": false, "supportsStaticESM": true, "useESM": true} 1`] = ` { - "allowSyntheticDefaultImports": true, + "allowSyntheticDefaultImports": undefined, "esModuleInterop": true, "module": 1, } @@ -50,7 +50,7 @@ exports[`TsCompiler getCompiledOutput isolatedModules true should transpile code exports[`TsCompiler getCompiledOutput isolatedModules true should transpile code with config {"babelConfig": false, "supportsStaticESM": true, "useESM": true} 1`] = ` { - "allowSyntheticDefaultImports": true, + "allowSyntheticDefaultImports": undefined, "esModuleInterop": true, "module": 1, } diff --git a/src/legacy/compiler/ts-compiler.ts b/src/legacy/compiler/ts-compiler.ts index 3dd57fc89d..43a8fa0202 100644 --- a/src/legacy/compiler/ts-compiler.ts +++ b/src/legacy/compiler/ts-compiler.ts @@ -172,7 +172,6 @@ export class TsCompiler implements TsCompilerInstance { ...compilerOptions, module: moduleKind, esModuleInterop: esModuleInterop ?? false, - allowSyntheticDefaultImports: esModuleInterop ?? compilerOptions.allowSyntheticDefaultImports, } } diff --git a/src/legacy/config/config-set.spec.ts b/src/legacy/config/config-set.spec.ts index ebcb658c1b..40ffb4c63c 100644 --- a/src/legacy/config/config-set.spec.ts +++ b/src/legacy/config/config-set.spec.ts @@ -97,7 +97,6 @@ describe('parsedTsConfig', () => { expect(cs.parsedTsConfig.options).toMatchObject({ module: ts.ModuleKind.AMD, - allowSyntheticDefaultImports: true, esModuleInterop: false, }) expect(target.lines.warn.join()).toEqual(expect.stringContaining(Errors.ConfigNoModuleInterop)) @@ -839,7 +838,6 @@ describe('_resolveTsConfig', () => { expect(readConfig.mock.calls[0][0]).toBe(tscfgPathStub) expect(parseConfig.mock.calls[0][2]).toBe('/root') expect(parseConfig.mock.calls[0][4]).toBe(tscfgPathStub) - expect(conf.options.allowSyntheticDefaultImports).toEqual(true) expect(conf.errors).toMatchSnapshot() }) diff --git a/src/legacy/config/config-set.ts b/src/legacy/config/config-set.ts index 10165f315d..a35939c099 100644 --- a/src/legacy/config/config-set.ts +++ b/src/legacy/config/config-set.ts @@ -487,11 +487,6 @@ export class ConfigSet { start: undefined, length: undefined, }) - // at least enable synthetic default imports (except if it's set in the input config) - /* istanbul ignore next (already covered in unit test) */ - if (!('allowSyntheticDefaultImports' in finalOptions)) { - finalOptions.allowSyntheticDefaultImports = true - } } // Make sure when allowJs is enabled, outDir is required to have when using allowJs: true if (finalOptions.allowJs && !finalOptions.outDir) {