Merge pull request #1856 from asger-semmle/ts-base-types

Approved by xiemaisi
This commit is contained in:
semmle-qlci
2019-09-03 10:12:30 +01:00
committed by GitHub
8 changed files with 27 additions and 2 deletions

View File

@@ -974,8 +974,10 @@ export class TypeTable {
if (superType == null) continue;
let baseTypeSymbol = superType.symbol;
if (baseTypeSymbol == null) continue;
let baseId = this.getSymbolId(baseTypeSymbol);
// Note: take care not to perform a recursive call between the two `push` calls.
this.baseTypes.symbols.push(symbolId);
this.baseTypes.baseTypeSymbols.push(this.getSymbolId(baseTypeSymbol));
this.baseTypes.baseTypeSymbols.push(baseId);
}
}
}

View File

@@ -210,7 +210,9 @@ class CanonicalName extends @symbol {
class TypeName extends CanonicalName {
TypeName() {
exists(TypeReference ref | type_symbol(ref, this)) or
exists(TypeDefinition def | ast_node_symbol(def, this))
exists(TypeDefinition def | ast_node_symbol(def, this)) or
base_type_names(_, this) or
base_type_names(this, _)
}
/**

View File

@@ -0,0 +1,3 @@
| B in module 'mylib' | A in module 'mylib' |
| C in module 'mylib' | B in module 'mylib' |
| D in module 'mylib' | C in module 'mylib' |

View File

@@ -0,0 +1,5 @@
import javascript
from TypeName tn
where tn.hasQualifiedName("mylib", _)
select tn, tn.getABaseTypeName()

View File

@@ -0,0 +1,4 @@
export interface A {}
export interface B extends A {}
export interface C extends B {}
export interface D extends C {}

View File

@@ -0,0 +1 @@
semmle-extractor-options:--exclude node_modules/**

View File

@@ -0,0 +1,5 @@
{
"compilerOptions": {
"baseUrl": "./"
}
}

View File

@@ -0,0 +1,3 @@
import { D } from "mylib";
export var foo: D = null;