Skip to content

Commit 0db788b

Browse files
committed
use direct string comparison instead, that doesn't crash on invalid values
1 parent 5e91b2f commit 0db788b

File tree

1 file changed

+3
-3
lines changed
  • javascript/extractor/lib/typescript/src

1 file changed

+3
-3
lines changed

javascript/extractor/lib/typescript/src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ function handleOpenProjectCommand(command: OpenProjectCommand) {
554554
let program = project.program;
555555
let typeChecker = program.getTypeChecker();
556556

557-
let shouldReportDiagnostics = getEnvironmentVariable("SEMMLE_TYPESCRIPT_REPORT_DIAGNOSTICS", v => JSON.parse(v.toLowerCase()), false);
557+
let shouldReportDiagnostics = getEnvironmentVariable("SEMMLE_TYPESCRIPT_REPORT_DIAGNOSTICS", v => v.trim().toLowerCase() === "true", false);
558558
let diagnostics = shouldReportDiagnostics
559559
? program.getSemanticDiagnostics().filter(d => d.category === ts.DiagnosticCategory.Error)
560560
: [];
@@ -807,8 +807,8 @@ function handleGetMetadataCommand(command: GetMetadataCommand) {
807807

808808
function reset() {
809809
state = new State();
810-
state.typeTable.restrictedExpansion = getEnvironmentVariable("SEMMLE_TYPESCRIPT_NO_EXPANSION", v => JSON.parse(v.toLowerCase()), true);
811-
state.typeTable.skipExtractingTypes = getEnvironmentVariable("CODEQL_EXTRACTOR_JAVASCRIPT_OPTION_SKIP_TYPES", v => JSON.parse(v.toLowerCase()), false);
810+
state.typeTable.restrictedExpansion = getEnvironmentVariable("SEMMLE_TYPESCRIPT_NO_EXPANSION", v => v.trim().toLowerCase() === "true", true);
811+
state.typeTable.skipExtractingTypes = getEnvironmentVariable("CODEQL_EXTRACTOR_JAVASCRIPT_OPTION_SKIP_TYPES", v => v.trim().toLowerCase() === "true", false);
812812
}
813813

814814
function getEnvironmentVariable<T>(name: string, parse: (x: string) => T, defaultValue: T) {

0 commit comments

Comments
 (0)