Skip to content

Commit 896432b

Browse files
committed
add environment variable to skip extraction of types in TypeScript
1 parent cf31ef4 commit 896432b

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export function augmentAst(ast: AugmentedSourceFile, code: string, project: Proj
192192
}
193193

194194
if (typeChecker != null) {
195-
if (isTypedNode(node)) {
195+
if (isTypedNode(node) && !typeTable.skipExtractingTypes) {
196196
let contextualType = isContextuallyTypedNode(node)
197197
? typeChecker.getContextualType(node)
198198
: null;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ function handleGetMetadataCommand(command: GetMetadataCommand) {
808808
function reset() {
809809
state = new State();
810810
state.typeTable.restrictedExpansion = getEnvironmentVariable("SEMMLE_TYPESCRIPT_NO_EXPANSION", Boolean, true);
811+
state.typeTable.skipExtractingTypes = getEnvironmentVariable("SEMMLE_TYPESCRIPT_SKIP_EXTRACTING_TYPES", Boolean, false);
811812
}
812813

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

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ export class TypeTable {
383383
*/
384384
public restrictedExpansion = false;
385385

386+
/**
387+
* If set to true, skip extracting types.
388+
*/
389+
public skipExtractingTypes = false;
390+
386391
private virtualSourceRoot: VirtualSourceRoot;
387392

388393
/**

0 commit comments

Comments
 (0)