mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #1856 from asger-semmle/ts-base-types
Approved by xiemaisi
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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, _)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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' |
|
||||
@@ -0,0 +1,5 @@
|
||||
import javascript
|
||||
|
||||
from TypeName tn
|
||||
where tn.hasQualifiedName("mylib", _)
|
||||
select tn, tn.getABaseTypeName()
|
||||
4
javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/node_modules/@types/mylib/index.d.ts
generated
vendored
Normal file
4
javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/node_modules/@types/mylib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export interface A {}
|
||||
export interface B extends A {}
|
||||
export interface C extends B {}
|
||||
export interface D extends C {}
|
||||
@@ -0,0 +1 @@
|
||||
semmle-extractor-options:--exclude node_modules/**
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { D } from "mylib";
|
||||
|
||||
export var foo: D = null;
|
||||
Reference in New Issue
Block a user