зеркало из https://github.com/github/codeql.git
JS: Enable type extraction inside conditional types again
This commit is contained in:
Родитель
4f5c06fed7
Коммит
1a0abfa7a5
|
@ -168,20 +168,9 @@ export function augmentAst(ast: AugmentedSourceFile, code: string, project: Proj
|
|||
}
|
||||
}
|
||||
|
||||
// Number of conditional type expressions the visitor is currently inside.
|
||||
// We disable type extraction inside such type expressions, to avoid complications
|
||||
// with `infer` types.
|
||||
let insideConditionalTypes = 0;
|
||||
|
||||
visitAstNode(ast);
|
||||
function visitAstNode(node: AugmentedNode) {
|
||||
if (node.kind === ts.SyntaxKind.ConditionalType) {
|
||||
++insideConditionalTypes;
|
||||
}
|
||||
ts.forEachChild(node, visitAstNode);
|
||||
if (node.kind === ts.SyntaxKind.ConditionalType) {
|
||||
--insideConditionalTypes;
|
||||
}
|
||||
|
||||
// fill in line/column info
|
||||
if ("pos" in node) {
|
||||
|
@ -202,7 +191,7 @@ export function augmentAst(ast: AugmentedSourceFile, code: string, project: Proj
|
|||
}
|
||||
}
|
||||
|
||||
if (typeChecker != null && insideConditionalTypes === 0) {
|
||||
if (typeChecker != null) {
|
||||
if (isTypedNode(node)) {
|
||||
let contextualType = isContextuallyTypedNode(node)
|
||||
? typeChecker.getContextualType(node)
|
||||
|
|
Загрузка…
Ссылка в новой задаче