mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
TS: Resolve imports using TypeScript symbols
This commit is contained in:
@@ -148,6 +148,16 @@ abstract class Import extends ASTNode {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the imported module, as determined by the TypeScript compiler, if any.
|
||||
*/
|
||||
private Module resolveFromTypeScriptSymbol() {
|
||||
exists(CanonicalName symbol |
|
||||
ast_node_symbol(this, symbol) and
|
||||
ast_node_symbol(result, symbol)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the module this import refers to.
|
||||
*
|
||||
@@ -162,7 +172,8 @@ abstract class Import extends ASTNode {
|
||||
else (
|
||||
result = resolveAsProvidedModule() or
|
||||
result = resolveImportedPath() or
|
||||
result = resolveFromTypeRoot()
|
||||
result = resolveFromTypeRoot() or
|
||||
result = resolveFromTypeScriptSymbol()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -688,7 +688,7 @@ case @symbol.kind of
|
||||
;
|
||||
|
||||
@type_with_symbol = @typereference | @typevariabletype | @typeoftype | @uniquesymboltype;
|
||||
@ast_node_with_symbol = @typedefinition | @namespacedefinition | @toplevel | @typeaccess | @namespaceaccess | @vardecl | @function | @invokeexpr;
|
||||
@ast_node_with_symbol = @typedefinition | @namespacedefinition | @toplevel | @typeaccess | @namespaceaccess | @vardecl | @function | @invokeexpr | @importdeclaration | @externalmodulereference;
|
||||
|
||||
ast_node_symbol(
|
||||
unique int node: @ast_node_with_symbol ref,
|
||||
|
||||
Reference in New Issue
Block a user