Skip to content

Commit 7f0f4f0

Browse files
committed
JS: Deprecate TypeAnnotation.hasQualifiedName
1 parent e2b3392 commit 7f0f4f0

5 files changed

Lines changed: 27 additions & 11 deletions

File tree

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ module API {
744744
MkModuleImport(string m) {
745745
imports(_, m)
746746
or
747-
any(TypeAnnotation n).hasQualifiedName(m, _)
747+
any(TypeAnnotation n).hasUnderlyingType(m, _)
748748
or
749749
any(Type t).hasUnderlyingType(m, _)
750750
} or
@@ -753,7 +753,7 @@ module API {
753753
MkUse(DataFlow::Node nd) { use(_, _, nd) } or
754754
/** A use of a TypeScript type. */
755755
MkTypeUse(string moduleName, string exportName) {
756-
any(TypeAnnotation n).hasQualifiedName(moduleName, exportName)
756+
any(TypeAnnotation n).hasUnderlyingType(moduleName, exportName)
757757
or
758758
any(Type t).hasUnderlyingType(moduleName, exportName)
759759
} or

javascript/ql/lib/semmle/javascript/TypeAnnotations.qll

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,36 @@ class TypeAnnotation extends @type_annotation, NodeInStmtContainer {
7777
TypeAnnotation getAnUnderlyingType() { result = this }
7878

7979
/**
80+
* DEPRECATED. Use `hasUnderlyingType` instead.
81+
*
8082
* Holds if this is a reference to the type with qualified name `globalName` relative to the global scope.
8183
*/
82-
final predicate hasQualifiedName(string globalName) {
84+
deprecated predicate hasQualifiedName(string globalName) {
8385
UnderlyingTypes::nodeHasUnderlyingType(this, "global", globalName)
8486
}
8587

8688
/**
89+
* DEPRECATED. Use `hasUnderlyingType` instead.
90+
*
8791
* Holds if this is a reference to the type exported from `moduleName` under the name `exportedName`.
8892
*/
89-
final predicate hasQualifiedName(string moduleName, string exportedName) {
93+
deprecated predicate hasQualifiedName(string moduleName, string exportedName) {
94+
UnderlyingTypes::nodeHasUnderlyingType(this, moduleName, exportedName)
95+
}
96+
97+
/**
98+
* Holds if this is a reference to the type with qualified name `globalName` relative to the global scope,
99+
* or is declared as a subtype thereof, or is a union or intersection containing such a type.
100+
*/
101+
final predicate hasUnderlyingType(string globalName) {
102+
UnderlyingTypes::nodeHasUnderlyingType(this, "global", globalName)
103+
}
104+
105+
/**
106+
* Holds if this is a reference to the type exported from `moduleName` under the name `exportedName`,
107+
* or is declared as a subtype thereof, or is a union or intersection containing such a type.
108+
*/
109+
final predicate hasUnderlyingType(string moduleName, string exportedName) {
90110
UnderlyingTypes::nodeHasUnderlyingType(this, moduleName, exportedName)
91111
}
92112

javascript/ql/lib/semmle/javascript/frameworks/Nest.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ module NestJS {
237237
CustomPipeClass() {
238238
exists(ClassDefinition cls |
239239
this = cls.flow() and
240-
cls.getASuperInterface().hasQualifiedName("@nestjs/common", "PipeTransform")
240+
cls.getASuperInterface().hasUnderlyingType("@nestjs/common", "PipeTransform")
241241
)
242242
}
243243

javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ predicate isPackageUsed(string package) {
6262
or
6363
any(JS::TypeName t).hasQualifiedName(package, _)
6464
or
65-
any(JS::TypeAnnotation t).hasQualifiedName(package, _)
65+
any(JS::TypeAnnotation t).hasUnderlyingType(package, _)
6666
or
6767
exists(JS::PackageJson json | json.getPackageName() = package)
6868
}

javascript/ql/lib/semmle/javascript/frameworks/jQuery.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ private predicate neverReturnsJQuery(string name) {
6060
decl.getBaseName() = "jQuery" and
6161
decl.getName() = name
6262
|
63-
not decl.getDocumentation()
64-
.getATagByTitle("return")
65-
.getType()
66-
.getAnUnderlyingType()
67-
.hasQualifiedName("jQuery")
63+
not decl.getDocumentation().getATagByTitle("return").getType().hasUnderlyingType("jQuery")
6864
)
6965
}
7066

0 commit comments

Comments
 (0)