diff --git a/packages/ast-spec/src/expression/ImportExpression/spec.ts b/packages/ast-spec/src/expression/ImportExpression/spec.ts index 9365bdae6265..3d52e111a8af 100644 --- a/packages/ast-spec/src/expression/ImportExpression/spec.ts +++ b/packages/ast-spec/src/expression/ImportExpression/spec.ts @@ -4,6 +4,22 @@ import type { Expression } from '../../unions/Expression'; export interface ImportExpression extends BaseNode { type: AST_NODE_TYPES.ImportExpression; + /** + * The attributes declared for the dynamic import. + * @example + * ```ts + * import('mod', \{ assert: \{ type: 'json' \} \}); + * ``` + * @deprecated Replaced with {@link `options`}. + */ attributes: Expression | null; + /** + * The options bag declared for the dynamic import. + * @example + * ```ts + * import('mod', \{ assert: \{ type: 'json' \} \}); + * ``` + */ + options: Expression | null; source: Expression; } diff --git a/packages/ast-spec/src/legacy-fixtures/basics/fixtures/dynamic-import-with-import-assertions/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/legacy-fixtures/basics/fixtures/dynamic-import-with-import-assertions/snapshots/1-TSESTree-AST.shot index 75537c0edbdd..cf35251a3a58 100644 --- a/packages/ast-spec/src/legacy-fixtures/basics/fixtures/dynamic-import-with-import-assertions/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/basics/fixtures/dynamic-import-with-import-assertions/snapshots/1-TSESTree-AST.shot @@ -8,7 +8,7 @@ Program { type: "ExpressionStatement", expression: ImportExpression { type: "ImportExpression", - attributes: ObjectExpression { + options: ObjectExpression { type: "ObjectExpression", properties: [ Property { diff --git a/packages/ast-spec/src/legacy-fixtures/basics/fixtures/dynamic-import-with-import-assertions/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/legacy-fixtures/basics/fixtures/dynamic-import-with-import-assertions/snapshots/5-AST-Alignment-AST.shot index 716706840f94..368720ed8e62 100644 --- a/packages/ast-spec/src/legacy-fixtures/basics/fixtures/dynamic-import-with-import-assertions/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/basics/fixtures/dynamic-import-with-import-assertions/snapshots/5-AST-Alignment-AST.shot @@ -12,15 +12,14 @@ exports[`AST Fixtures legacy-fixtures basics dynamic-import-with-import-assertio type: 'ExpressionStatement', expression: ImportExpression { type: 'ImportExpression', - attributes: ObjectExpression { - type: 'ObjectExpression', - properties: Array [ - Property { - type: 'Property', - computed: false, - key: Identifier { - type: 'Identifier', -- decorators: Array [], ++ attributes: ObjectExpression { ++ type: 'ObjectExpression', ++ properties: Array [ ++ Property { ++ type: 'Property', ++ computed: false, ++ key: Identifier { ++ type: 'Identifier', + name: 'assert', + + range: [89, 95], @@ -92,14 +91,15 @@ exports[`AST Fixtures legacy-fixtures basics dynamic-import-with-import-assertio + end: { column: 42, line: 3 }, + }, + }, -+ options: ObjectExpression { -+ type: 'ObjectExpression', -+ properties: Array [ -+ Property { -+ type: 'Property', -+ computed: false, -+ key: Identifier { -+ type: 'Identifier', + options: ObjectExpression { + type: 'ObjectExpression', + properties: Array [ + Property { + type: 'Property', + computed: false, + key: Identifier { + type: 'Identifier', +- decorators: Array [], name: 'assert', - optional: false, diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index b014d885bf31..d32d4d54e926 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2435,13 +2435,21 @@ export class Converter { 'Dynamic import requires exactly one or two arguments.', ); } - return this.createNode(node, { - type: AST_NODE_TYPES.ImportExpression, - attributes: node.arguments[1] - ? this.convertChild(node.arguments[1]) - : null, - source: this.convertChild(node.arguments[0]), - }); + return this.createNode( + node, + this.#withDeprecatedAliasGetter( + { + type: AST_NODE_TYPES.ImportExpression, + options: node.arguments[1] + ? this.convertChild(node.arguments[1]) + : null, + source: this.convertChild(node.arguments[0]), + }, + 'attributes', + 'options', + true, + ), + ); } const callee = this.convertChild(node.expression); diff --git a/packages/visitor-keys/src/visitor-keys.ts b/packages/visitor-keys/src/visitor-keys.ts index 935171d8c25b..0aa7a24450fe 100644 --- a/packages/visitor-keys/src/visitor-keys.ts +++ b/packages/visitor-keys/src/visitor-keys.ts @@ -175,7 +175,7 @@ const additionalKeys: AdditionalKeys = { Identifier: ['decorators', 'typeAnnotation'], ImportAttribute: ['key', 'value'], ImportDeclaration: ['specifiers', 'source', 'assertions'], - ImportExpression: ['source', 'attributes'], + ImportExpression: ['source', 'options'], JSXClosingFragment: [], JSXOpeningElement: ['name', 'typeArguments', 'attributes'], JSXOpeningFragment: [], pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy