JS: Move isTypeOnly() check into a direct check, instead of an override

This commit is contained in:
Asger F
2025-11-21 13:10:32 +01:00
parent 9c4f85f15b
commit 51e1bda608

View File

@@ -543,13 +543,16 @@ class ExportNamedDeclaration extends ExportDeclaration, @export_named_declaratio
VarDecl getADecl() { result = this.getAnExportedDecl() }
override predicate exportsDirectlyAs(LexicalName v, string name) {
exists(LexicalDecl vd | vd = this.getAnExportedDecl() |
name = vd.getName() and v = vd.getALexicalName()
)
or
exists(ExportSpecifier spec | spec = this.getASpecifier() and name = spec.getExportedName() |
v = spec.getLocal().(LexicalAccess).getALexicalName()
)
(
exists(LexicalDecl vd | vd = this.getAnExportedDecl() |
name = vd.getName() and v = vd.getALexicalName()
)
or
exists(ExportSpecifier spec | spec = this.getASpecifier() and name = spec.getExportedName() |
v = spec.getLocal().(LexicalAccess).getALexicalName()
)
) and
not (this.isTypeOnly() and v instanceof Variable)
}
override DataFlow::Node getDirectSourceNode(string name) {
@@ -600,18 +603,6 @@ private class ExportNamespaceStep extends PreCallGraphStep {
}
}
/**
* An export declaration with the `type` modifier.
*/
private class TypeOnlyExportDeclaration extends ExportNamedDeclaration {
TypeOnlyExportDeclaration() { this.isTypeOnly() }
override predicate exportsDirectlyAs(LexicalName v, string name) {
super.exportsDirectlyAs(v, name) and
not v instanceof Variable
}
}
/**
* An export specifier in an export declaration.
*
@@ -834,7 +825,8 @@ class SelectiveReExportDeclaration extends ReExportDeclaration, ExportNamedDecla
override predicate reExportsAs(LexicalName v, string name) {
exists(ExportSpecifier spec | spec = this.getASpecifier() and name = spec.getExportedName() |
this.getReExportedES2015Module().exportsAs(v, spec.getLocalName())
)
) and
not (this.isTypeOnly() and v instanceof Variable)
}
overlay[global]