Skip to content

Commit 9133e7a

Browse files
authored
Use defaults for transpileModule (microsoft#31563)
1 parent 05af8fa commit 9133e7a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/services/transpile.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ namespace ts {
2626
export function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput {
2727
const diagnostics: Diagnostic[] = [];
2828

29-
const options: CompilerOptions = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : getDefaultCompilerOptions();
29+
const options: CompilerOptions = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {};
30+
31+
// mix in default options
32+
const defaultOptions = getDefaultCompilerOptions();
33+
for (const key in defaultOptions) {
34+
if (hasProperty(defaultOptions, key) && options[key] === undefined) {
35+
options[key] = defaultOptions[key];
36+
}
37+
}
3038

3139
options.isolatedModules = true;
3240

src/testRunner/unittests/services/transpile.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ namespace ts {
1717

1818
transpileOptions = testSettings.options || {};
1919
if (!transpileOptions.compilerOptions) {
20-
transpileOptions.compilerOptions = {};
20+
transpileOptions.compilerOptions = { };
21+
}
22+
if (transpileOptions.compilerOptions.target === undefined) {
23+
transpileOptions.compilerOptions.target = ScriptTarget.ES3;
2124
}
2225

2326
if (transpileOptions.compilerOptions.newLine === undefined) {

0 commit comments

Comments
 (0)