Skip to content

Commit 8d857d5

Browse files
authored
🤖 Merge PR DefinitelyTyped#72206 [estree] add ImportAttribute by @zyoshoka
1 parent b20fdcd commit 8d857d5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

types/estree/estree-tests.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ declare var moduleDeclaration: ESTree.ModuleDeclaration;
8484
declare var moduleSpecifier: ESTree.ModuleSpecifier;
8585
declare var importDeclaration: ESTree.ImportDeclaration;
8686
declare var importSpecifier: ESTree.ImportSpecifier;
87+
declare var importAttribute: ESTree.ImportAttribute;
8788
declare var importDefaultSpecifier: ESTree.ImportDefaultSpecifier;
8889
declare var importNamespaceSpecifier: ESTree.ImportNamespaceSpecifier;
8990
declare var exportNamedDeclaration: ESTree.ExportNamedDeclaration;
@@ -261,6 +262,11 @@ if (memberExpressionOrCallExpression.type === "MemberExpression") {
261262
expressionOrSpread = callExpression.arguments[0];
262263
}
263264

265+
// ImportExpression
266+
var importExpression: ESTree.ImportExpression;
267+
expression = importExpression.source;
268+
expressionMaybe = importExpression.options;
269+
264270
// Declarations
265271
var functionDeclaration: ESTree.FunctionDeclaration;
266272
var identifierOrNull: ESTree.Identifier | null = functionDeclaration.id;
@@ -286,6 +292,7 @@ classDeclaration.id = null;
286292

287293
var identifierOrLiteral: ESTree.Identifier | ESTree.Literal;
288294
identifierOrLiteral = importSpecifier.imported;
295+
identifierOrLiteral = importAttribute.key;
289296
identifierOrLiteral = exportSpecifier.local;
290297
identifierOrLiteral = exportSpecifier.exported;
291298
var identifierOrLiteralOrNull: ESTree.Identifier | ESTree.Literal | null;

types/estree/index.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ export interface BaseModuleSpecifier extends BaseNode {
633633
export interface ImportDeclaration extends BaseModuleDeclaration {
634634
type: "ImportDeclaration";
635635
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
636+
attributes: ImportAttribute[];
636637
source: Literal;
637638
}
638639

@@ -641,9 +642,16 @@ export interface ImportSpecifier extends BaseModuleSpecifier {
641642
imported: Identifier | Literal;
642643
}
643644

645+
export interface ImportAttribute extends BaseNode {
646+
type: "ImportAttribute";
647+
key: Identifier | Literal;
648+
value: Literal;
649+
}
650+
644651
export interface ImportExpression extends BaseExpression {
645652
type: "ImportExpression";
646653
source: Expression;
654+
options?: Expression | null | undefined;
647655
}
648656

649657
export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
@@ -658,6 +666,7 @@ export interface ExportNamedDeclaration extends BaseModuleDeclaration {
658666
type: "ExportNamedDeclaration";
659667
declaration?: Declaration | null | undefined;
660668
specifiers: ExportSpecifier[];
669+
attributes: ImportAttribute[];
661670
source?: Literal | null | undefined;
662671
}
663672

@@ -675,6 +684,7 @@ export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
675684
export interface ExportAllDeclaration extends BaseModuleDeclaration {
676685
type: "ExportAllDeclaration";
677686
exported: Identifier | Literal | null;
687+
attributes: ImportAttribute[];
678688
source: Literal;
679689
}
680690

0 commit comments

Comments
 (0)