Skip to content

Commit ff082eb

Browse files
authored
Merge pull request #11070 from zhengbli/allowSynthetic
set allowSyntheticDefaultImports to true by default for jsconfig.json
2 parents 0a0b7e4 + 12578a5 commit ff082eb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/compiler/commandLineParser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,9 @@ namespace ts {
901901
function convertCompilerOptionsFromJsonWorker(jsonOptions: any,
902902
basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions {
903903

904-
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {};
904+
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json"
905+
? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true }
906+
: {};
905907
convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors);
906908
return options;
907909
}

src/harness/unittests/convertCompilerOptionsFromJson.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ namespace ts {
404404
compilerOptions: <CompilerOptions>{
405405
allowJs: true,
406406
maxNodeModuleJsDepth: 2,
407+
allowSyntheticDefaultImports: true,
407408
module: ModuleKind.CommonJS,
408409
target: ScriptTarget.ES5,
409410
noImplicitAny: false,
@@ -431,6 +432,7 @@ namespace ts {
431432
compilerOptions: <CompilerOptions>{
432433
allowJs: false,
433434
maxNodeModuleJsDepth: 2,
435+
allowSyntheticDefaultImports: true,
434436
module: ModuleKind.CommonJS,
435437
target: ScriptTarget.ES5,
436438
noImplicitAny: false,
@@ -453,7 +455,8 @@ namespace ts {
453455
compilerOptions:
454456
{
455457
allowJs: true,
456-
maxNodeModuleJsDepth: 2
458+
maxNodeModuleJsDepth: 2,
459+
allowSyntheticDefaultImports: true
457460
},
458461
errors: [{
459462
file: undefined,
@@ -473,7 +476,8 @@ namespace ts {
473476
compilerOptions:
474477
{
475478
allowJs: true,
476-
maxNodeModuleJsDepth: 2
479+
maxNodeModuleJsDepth: 2,
480+
allowSyntheticDefaultImports: true
477481
},
478482
errors: <Diagnostic[]>[]
479483
}

0 commit comments

Comments
 (0)