Skip to content

Commit 9ef9b74

Browse files
author
Andy Hanson
committed
Fix module loading error
(commandLineOptions_stringToEnum would be undefined if optionDeclarations wasn't loaded yet)
1 parent 0aa2fe3 commit 9ef9b74

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/services/services.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1920,12 +1920,16 @@ namespace ts {
19201920
sourceMapText?: string;
19211921
}
19221922

1923-
const commandLineOptions_stringToEnum = <CommandLineOptionOfCustomType[]>filter(optionDeclarations, o => {
1924-
return typeof o.type === "object" && !forEachValue(<Map<any>> o.type, v => typeof v !== "number");
1925-
});
1923+
1924+
1925+
let commandLineOptions_stringToEnum: CommandLineOptionOfCustomType[];
19261926

19271927
/** JS users may pass in string values for enum compiler options (such as ModuleKind), so convert. */
1928-
function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]) {
1928+
function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions {
1929+
// Lazily create this value to fix module loading errors.
1930+
commandLineOptions_stringToEnum = commandLineOptions_stringToEnum || <CommandLineOptionOfCustomType[]>filter(optionDeclarations, o =>
1931+
typeof o.type === "object" && !forEachValue(<Map<any>> o.type, v => typeof v !== "number"));
1932+
19291933
options = clone(options);
19301934

19311935
for (const opt of commandLineOptions_stringToEnum) {

0 commit comments

Comments
 (0)