Skip to content

Commit 8a893f2

Browse files
committed
fix(migrate): auto-remove allowSyntheticDefaultImports: false from tsconfig.json
Same deprecation reason as esModuleInterop: false — tsgolint no longer supports these options set to false. Generalize the removal into a reusable `removeDeprecatedTsconfigFalseOption` function and apply it to both options during migration. See oxc-project/tsgolint#351
1 parent 2f47f2d commit 8a893f2

File tree

5 files changed

+187
-144
lines changed

5 files changed

+187
-144
lines changed

packages/cli/snap-tests-global/migration-tsconfig-esmoduleinterop/snap.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ VITE+ - The Unified Toolchain for the Web
33

44
◇ Migrated . to Vite+<repeat>
55
• Node <semver> pnpm <semver>
6-
3 config updates applied
6+
4 config updates applied
77
! Warnings:
88
- Removed `"esModuleInterop": false` from tsconfig.json — this option has been deprecated. See https://github.com/oxc-project/tsgolint/issues/351, https://github.com/microsoft/TypeScript/issues/62529
9+
- Removed `"allowSyntheticDefaultImports": false` from tsconfig.json — this option has been deprecated. See https://github.com/oxc-project/tsgolint/issues/351, https://github.com/microsoft/TypeScript/issues/62529
910

1011
> cat tsconfig.json # verify esModuleInterop: false is removed
1112
{
1213
"compilerOptions": {
1314
"target": "ES2023",
1415
"module": "ESNext",
15-
"allowSyntheticDefaultImports": true,
1616
"strict": true
1717
}
1818
}

packages/cli/snap-tests-global/migration-tsconfig-esmoduleinterop/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"target": "ES2023",
44
"module": "ESNext",
55
"esModuleInterop": false,
6-
"allowSyntheticDefaultImports": true,
6+
"allowSyntheticDefaultImports": false,
77
"strict": true
88
}
99
}

packages/cli/src/migration/migrator.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { getSpinner } from '../utils/prompts.js';
3131
import {
3232
findTsconfigFiles,
3333
hasBaseUrlInTsconfig,
34-
removeEsModuleInteropFalseFromFile,
34+
removeDeprecatedTsconfigFalseOption,
3535
} from '../utils/tsconfig.js';
3636
import { editYamlFile, scalarString, type YamlDocument } from '../utils/yaml.js';
3737
import {
@@ -652,19 +652,22 @@ function cleanupDeprecatedTsconfigOptions(
652652
silent = false,
653653
report?: MigrationReport,
654654
): void {
655+
const deprecatedOptions = ['esModuleInterop', 'allowSyntheticDefaultImports'];
655656
const files = findTsconfigFiles(projectPath);
656657
for (const filePath of files) {
657-
if (removeEsModuleInteropFalseFromFile(filePath)) {
658-
if (report) {
659-
report.removedConfigCount++;
660-
}
661-
if (!silent) {
662-
prompts.log.success(`✔ Removed esModuleInterop: false from ${displayRelative(filePath)}`);
658+
for (const name of deprecatedOptions) {
659+
if (removeDeprecatedTsconfigFalseOption(filePath, name)) {
660+
if (report) {
661+
report.removedConfigCount++;
662+
}
663+
if (!silent) {
664+
prompts.log.success(`✔ Removed ${name}: false from ${displayRelative(filePath)}`);
665+
}
666+
warnMigration(
667+
`Removed \`"${name}": false\` from ${displayRelative(filePath)} — this option has been deprecated. See https://github.com/oxc-project/tsgolint/issues/351, https://github.com/microsoft/TypeScript/issues/62529`,
668+
report,
669+
);
663670
}
664-
warnMigration(
665-
`Removed \`"esModuleInterop": false\` from ${displayRelative(filePath)} — this option has been deprecated. See https://github.com/oxc-project/tsgolint/issues/351, https://github.com/microsoft/TypeScript/issues/62529`,
666-
report,
667-
);
668671
}
669672
}
670673
}

0 commit comments

Comments
 (0)