Skip to content

Commit d1a7fee

Browse files
committed
disable import resolution on type-only import specifiers
1 parent d946802 commit d1a7fee

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

javascript/ql/lib/semmle/javascript/DefUse.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private predicate defn(ControlFlowNode def, Expr lhs, AST::ValueNode rhs) {
4242
lhs = i.getIdentifier() and rhs = i.getImportedEntity()
4343
)
4444
or
45-
exists(ImportSpecifier i | def = i | lhs = i.getLocal() and rhs = i)
45+
exists(ImportSpecifier i | def = i and not i.isTypeOnly() | lhs = i.getLocal() and rhs = i)
4646
or
4747
exists(EnumMember member | def = member.getIdentifier() |
4848
lhs = def and rhs = member.getInitializer()

javascript/ql/lib/semmle/javascript/dataflow/DataFlow.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ module DataFlow {
881881

882882
ImportSpecifierAsPropRead() {
883883
astNode = imprt.getASpecifier() and
884+
not astNode.isTypeOnly() and
884885
exists(astNode.getImportedName())
885886
}
886887

javascript/ql/lib/semmle/javascript/dataflow/internal/InterModuleTypeInference.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ private import AbstractPropertiesImpl
1515
private class AnalyzedImportSpecifier extends AnalyzedVarDef, @import_specifier {
1616
ImportDeclaration id;
1717

18-
AnalyzedImportSpecifier() { this = id.getASpecifier() and exists(id.resolveImportedPath()) }
18+
AnalyzedImportSpecifier() {
19+
this = id.getASpecifier() and
20+
exists(id.resolveImportedPath()) and
21+
not this.(ImportSpecifier).isTypeOnly()
22+
}
1923

2024
override DataFlow::AnalyzedNode getRhs() { result.(AnalyzedImport).getImportSpecifier() = this }
2125

@@ -135,10 +139,12 @@ private predicate incompleteExport(ES2015Module m, string y) {
135139
*/
136140
private class AnalyzedImport extends AnalyzedPropertyRead, DataFlow::ValueNode {
137141
Module imported;
142+
override ImportSpecifier astNode;
138143

139144
AnalyzedImport() {
140145
exists(ImportDeclaration id |
141146
astNode = id.getASpecifier() and
147+
not astNode.isTypeOnly() and
142148
imported = id.getImportedModule()
143149
)
144150
}

0 commit comments

Comments
 (0)