@@ -1396,6 +1396,58 @@ class QualifiedNamespaceAccess extends NamespaceAccess, @qualifiednamespaceacces
13961396 override Identifier getIdentifier ( ) { result = getChildTypeExpr ( 1 ) }
13971397}
13981398
1399+ /**
1400+ * An import inside a type annotation, such as in `import("http").ServerRequest`.
1401+ */
1402+ class ImportTypeExpr extends TypeExpr , @importtypeexpr {
1403+ /**
1404+ * Gets the string literal with the imported path, such as `"http"` in `import("http")`.
1405+ */
1406+ TypeExpr getPathExpr ( ) {
1407+ result = getChildTypeExpr ( 0 )
1408+ }
1409+
1410+ /**
1411+ * Gets the unresolved path string, such as `http` in `import("http")`.
1412+ */
1413+ string getPath ( ) {
1414+ result = getPathExpr ( ) .( StringLiteralTypeExpr ) .getValue ( )
1415+ }
1416+
1417+ /** Holds if this import is used in the context of a type, such as in `let x: import("foo")`. */
1418+ predicate isTypeAccess ( ) {
1419+ this instanceof @importtypeaccess
1420+ }
1421+
1422+ /** Holds if this import is used in the context of a namespace, such as in `let x: import("http").ServerRequest"`. */
1423+ predicate isNamespaceAccess ( ) {
1424+ this instanceof @importnamespaceaccess
1425+ }
1426+
1427+ /** Holds if this import is used in the context of a variable type, such as `let x: typeof import("fs")`. */
1428+ predicate isVarTypeAccess ( ) {
1429+ this instanceof @importvartypeaccess
1430+ }
1431+ }
1432+
1433+ /**
1434+ * An import used in the context of a type, such as in `let x: import("foo")`.
1435+ */
1436+ class ImportTypeAccess extends TypeAccess , ImportTypeExpr , @importtypeaccess {
1437+ }
1438+
1439+ /**
1440+ * An import used in the context of a namespace inside a type annotation, such as in `let x: import("http").ServerRequest`.
1441+ */
1442+ class ImportNamespaceAccess extends NamespaceAccess , ImportTypeExpr , @importnamespaceaccess {
1443+ }
1444+
1445+ /**
1446+ * An import used in the context of a variable type, such as in `let x: typeof import("fs")`.
1447+ */
1448+ class ImportVarTypeAccess extends VarTypeAccess , ImportTypeExpr , @importvartypeaccess {
1449+ }
1450+
13991451/**
14001452 * A TypeScript enum declaration, such as the following declaration:
14011453 * ```
0 commit comments