add environment variable to skip extraction of types in TypeScript

This commit is contained in:
erik-krogh
2023-12-12 12:25:00 +01:00
parent cf31ef4960
commit 896432b646
3 changed files with 7 additions and 1 deletions

View File

@@ -192,7 +192,7 @@ export function augmentAst(ast: AugmentedSourceFile, code: string, project: Proj
}
if (typeChecker != null) {
if (isTypedNode(node)) {
if (isTypedNode(node) && !typeTable.skipExtractingTypes) {
let contextualType = isContextuallyTypedNode(node)
? typeChecker.getContextualType(node)
: null;

View File

@@ -808,6 +808,7 @@ function handleGetMetadataCommand(command: GetMetadataCommand) {
function reset() {
state = new State();
state.typeTable.restrictedExpansion = getEnvironmentVariable("SEMMLE_TYPESCRIPT_NO_EXPANSION", Boolean, true);
state.typeTable.skipExtractingTypes = getEnvironmentVariable("SEMMLE_TYPESCRIPT_SKIP_EXTRACTING_TYPES", Boolean, false);
}
function getEnvironmentVariable<T>(name: string, parse: (x: string) => T, defaultValue: T) {

View File

@@ -383,6 +383,11 @@ export class TypeTable {
*/
public restrictedExpansion = false;
/**
* If set to true, skip extracting types.
*/
public skipExtractingTypes = false;
private virtualSourceRoot: VirtualSourceRoot;
/**