mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
JS: Add UnionOrIntersectionTypeExpr
This commit is contained in:
@@ -896,21 +896,28 @@ class ArrayTypeExpr extends @array_typeexpr, TypeExpr {
|
||||
override string getAPrimaryQlClass() { result = "ArrayTypeExpr" }
|
||||
}
|
||||
|
||||
private class RawUnionOrIntersectionTypeExpr = @union_typeexpr or @intersection_typeexpr;
|
||||
|
||||
/**
|
||||
* A union type, such as `string|number|boolean`.
|
||||
* A union or intersection type, such as `string|number|boolean` or `A & B`.
|
||||
*/
|
||||
class UnionTypeExpr extends @union_typeexpr, TypeExpr {
|
||||
/** Gets the `n`th type in the union, starting at 0. */
|
||||
class UnionOrIntersectionTypeExpr extends RawUnionOrIntersectionTypeExpr, TypeExpr {
|
||||
/** Gets the `n`th type in the union or intersection, starting at 0. */
|
||||
TypeExpr getElementType(int n) { result = this.getChildTypeExpr(n) }
|
||||
|
||||
/** Gets any of the types in the union. */
|
||||
/** Gets any of the types in the union or intersection. */
|
||||
TypeExpr getAnElementType() { result = this.getElementType(_) }
|
||||
|
||||
/** Gets the number of types in the union. This is always at least two. */
|
||||
/** Gets the number of types in the union or intersection. This is always at least two. */
|
||||
int getNumElementType() { result = count(this.getAnElementType()) }
|
||||
|
||||
override TypeExpr getAnUnderlyingType() { result = this.getAnElementType().getAnUnderlyingType() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A union type, such as `string|number|boolean`.
|
||||
*/
|
||||
class UnionTypeExpr extends @union_typeexpr, UnionOrIntersectionTypeExpr {
|
||||
override string getAPrimaryQlClass() { result = "UnionTypeExpr" }
|
||||
}
|
||||
|
||||
@@ -932,18 +939,7 @@ class IndexedAccessTypeExpr extends @indexed_access_typeexpr, TypeExpr {
|
||||
*
|
||||
* In general, there are can more than two operands to an intersection type.
|
||||
*/
|
||||
class IntersectionTypeExpr extends @intersection_typeexpr, TypeExpr {
|
||||
/** Gets the `n`th operand of the intersection type, starting at 0. */
|
||||
TypeExpr getElementType(int n) { result = this.getChildTypeExpr(n) }
|
||||
|
||||
/** Gets any of the operands to the intersection type. */
|
||||
TypeExpr getAnElementType() { result = this.getElementType(_) }
|
||||
|
||||
/** Gets the number of operands to the intersection type. This is always at least two. */
|
||||
int getNumElementType() { result = count(this.getAnElementType()) }
|
||||
|
||||
override TypeExpr getAnUnderlyingType() { result = this.getAnElementType().getAnUnderlyingType() }
|
||||
|
||||
class IntersectionTypeExpr extends @intersection_typeexpr, UnionOrIntersectionTypeExpr {
|
||||
override string getAPrimaryQlClass() { result = "IntersectionTypeExpr" }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user