From 33db5e9ac19a7c6dca5edd66f1210c3e1c3f0478 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Tue, 29 Apr 2025 11:35:16 +0100 Subject: [PATCH 1/3] fix(typescript-eslint): correct `TSImportType` property name when `assert` --- .../fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 142 +++++++++++++- .../snapshots/2-TSESTree-Tokens.shot | 180 ++++++++++++++++++ .../snapshots/3-Babel-AST.shot | 122 +++++++++++- .../snapshots/4-Babel-Tokens.shot | 180 ++++++++++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 146 +++++++++++++- .../snapshots/6-AST-Alignment-Tokens.shot | 180 ++++++++++++++++++ packages/typescript-estree/src/convert.ts | 15 +- 8 files changed, 955 insertions(+), 11 deletions(-) diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts index 64e365d93c03..1eeabf2f219b 100644 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts @@ -1,3 +1,4 @@ // TODO: This fixture might be too large, and if so should be split up. type A = import("A", { with: { type: "json" } }); +type B = import("B", { assert: { type: "json" } }); diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/1-TSESTree-AST.shot index 083b7e561f23..332768d18143 100644 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/1-TSESTree-AST.shot @@ -139,12 +139,150 @@ Program { end: { column: 49, line: 3 }, }, }, + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "B", + optional: false, + + range: [128, 129], + loc: { + start: { column: 5, line: 4 }, + end: { column: 6, line: 4 }, + }, + }, + typeAnnotation: TSImportType { + type: "TSImportType", + argument: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: ""B"", + value: "B", + + range: [139, 142], + loc: { + start: { column: 16, line: 4 }, + end: { column: 19, line: 4 }, + }, + }, + + range: [139, 142], + loc: { + start: { column: 16, line: 4 }, + end: { column: 19, line: 4 }, + }, + }, + options: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "assert", + optional: false, + + range: [146, 152], + loc: { + start: { column: 23, line: 4 }, + end: { column: 29, line: 4 }, + }, + }, + kind: "init", + method: false, + optional: false, + shorthand: false, + value: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "type", + optional: false, + + range: [156, 160], + loc: { + start: { column: 33, line: 4 }, + end: { column: 37, line: 4 }, + }, + }, + kind: "init", + method: false, + optional: false, + shorthand: false, + value: Literal { + type: "Literal", + raw: ""json"", + value: "json", + + range: [162, 168], + loc: { + start: { column: 39, line: 4 }, + end: { column: 45, line: 4 }, + }, + }, + + range: [156, 168], + loc: { + start: { column: 33, line: 4 }, + end: { column: 45, line: 4 }, + }, + }, + ], + + range: [154, 170], + loc: { + start: { column: 31, line: 4 }, + end: { column: 47, line: 4 }, + }, + }, + + range: [146, 170], + loc: { + start: { column: 23, line: 4 }, + end: { column: 47, line: 4 }, + }, + }, + ], + + range: [144, 172], + loc: { + start: { column: 21, line: 4 }, + end: { column: 49, line: 4 }, + }, + }, + qualifier: null, + typeArguments: null, + + range: [132, 173], + loc: { + start: { column: 9, line: 4 }, + end: { column: 50, line: 4 }, + }, + }, + + range: [123, 174], + loc: { + start: { column: 0, line: 4 }, + end: { column: 51, line: 4 }, + }, + }, ], sourceType: "script", - range: [73, 123], + range: [73, 175], loc: { start: { column: 0, line: 3 }, - end: { column: 0, line: 4 }, + end: { column: 0, line: 5 }, }, } \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/2-TSESTree-Tokens.shot index ee1cbc09cb3a..3a98006b3e92 100644 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/2-TSESTree-Tokens.shot @@ -179,4 +179,184 @@ end: { column: 49, line: 3 }, }, }, + Identifier { + type: "Identifier", + value: "type", + + range: [123, 127], + loc: { + start: { column: 0, line: 4 }, + end: { column: 4, line: 4 }, + }, + }, + Identifier { + type: "Identifier", + value: "B", + + range: [128, 129], + loc: { + start: { column: 5, line: 4 }, + end: { column: 6, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [130, 131], + loc: { + start: { column: 7, line: 4 }, + end: { column: 8, line: 4 }, + }, + }, + Keyword { + type: "Keyword", + value: "import", + + range: [132, 138], + loc: { + start: { column: 9, line: 4 }, + end: { column: 15, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [138, 139], + loc: { + start: { column: 15, line: 4 }, + end: { column: 16, line: 4 }, + }, + }, + String { + type: "String", + value: ""B"", + + range: [139, 142], + loc: { + start: { column: 16, line: 4 }, + end: { column: 19, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [142, 143], + loc: { + start: { column: 19, line: 4 }, + end: { column: 20, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [144, 145], + loc: { + start: { column: 21, line: 4 }, + end: { column: 22, line: 4 }, + }, + }, + Identifier { + type: "Identifier", + value: "assert", + + range: [146, 152], + loc: { + start: { column: 23, line: 4 }, + end: { column: 29, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [152, 153], + loc: { + start: { column: 29, line: 4 }, + end: { column: 30, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [154, 155], + loc: { + start: { column: 31, line: 4 }, + end: { column: 32, line: 4 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [156, 160], + loc: { + start: { column: 33, line: 4 }, + end: { column: 37, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [160, 161], + loc: { + start: { column: 37, line: 4 }, + end: { column: 38, line: 4 }, + }, + }, + String { + type: "String", + value: ""json"", + + range: [162, 168], + loc: { + start: { column: 39, line: 4 }, + end: { column: 45, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [169, 170], + loc: { + start: { column: 46, line: 4 }, + end: { column: 47, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [171, 172], + loc: { + start: { column: 48, line: 4 }, + end: { column: 49, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [172, 173], + loc: { + start: { column: 49, line: 4 }, + end: { column: 50, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [173, 174], + loc: { + start: { column: 50, line: 4 }, + end: { column: 51, line: 4 }, + }, + }, ] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/3-Babel-AST.shot index 824b498c0232..3de9ec6dd13f 100644 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/3-Babel-AST.shot @@ -119,12 +119,130 @@ Program { end: { column: 49, line: 3 }, }, }, + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "B", + + range: [128, 129], + loc: { + start: { column: 5, line: 4 }, + end: { column: 6, line: 4 }, + }, + }, + typeAnnotation: TSImportType { + type: "TSImportType", + argument: Literal { + type: "Literal", + raw: ""B"", + value: "B", + + range: [139, 142], + loc: { + start: { column: 16, line: 4 }, + end: { column: 19, line: 4 }, + }, + }, + options: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + name: "assert", + + range: [146, 152], + loc: { + start: { column: 23, line: 4 }, + end: { column: 29, line: 4 }, + }, + }, + kind: "init", + method: false, + shorthand: false, + value: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + name: "type", + + range: [156, 160], + loc: { + start: { column: 33, line: 4 }, + end: { column: 37, line: 4 }, + }, + }, + kind: "init", + method: false, + shorthand: false, + value: Literal { + type: "Literal", + raw: ""json"", + value: "json", + + range: [162, 168], + loc: { + start: { column: 39, line: 4 }, + end: { column: 45, line: 4 }, + }, + }, + + range: [156, 168], + loc: { + start: { column: 33, line: 4 }, + end: { column: 45, line: 4 }, + }, + }, + ], + + range: [154, 170], + loc: { + start: { column: 31, line: 4 }, + end: { column: 47, line: 4 }, + }, + }, + + range: [146, 170], + loc: { + start: { column: 23, line: 4 }, + end: { column: 47, line: 4 }, + }, + }, + ], + + range: [144, 172], + loc: { + start: { column: 21, line: 4 }, + end: { column: 49, line: 4 }, + }, + }, + + range: [132, 173], + loc: { + start: { column: 9, line: 4 }, + end: { column: 50, line: 4 }, + }, + }, + + range: [123, 174], + loc: { + start: { column: 0, line: 4 }, + end: { column: 51, line: 4 }, + }, + }, ], sourceType: "script", - range: [73, 123], + range: [73, 175], loc: { start: { column: 0, line: 3 }, - end: { column: 0, line: 4 }, + end: { column: 0, line: 5 }, }, } \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/4-Babel-Tokens.shot index 5ae289244c7c..102f865c6a01 100644 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/4-Babel-Tokens.shot @@ -179,4 +179,184 @@ end: { column: 49, line: 3 }, }, }, + Identifier { + type: "Identifier", + value: "type", + + range: [123, 127], + loc: { + start: { column: 0, line: 4 }, + end: { column: 4, line: 4 }, + }, + }, + Identifier { + type: "Identifier", + value: "B", + + range: [128, 129], + loc: { + start: { column: 5, line: 4 }, + end: { column: 6, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [130, 131], + loc: { + start: { column: 7, line: 4 }, + end: { column: 8, line: 4 }, + }, + }, + Keyword { + type: "Keyword", + value: "import", + + range: [132, 138], + loc: { + start: { column: 9, line: 4 }, + end: { column: 15, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [138, 139], + loc: { + start: { column: 15, line: 4 }, + end: { column: 16, line: 4 }, + }, + }, + String { + type: "String", + value: ""B"", + + range: [139, 142], + loc: { + start: { column: 16, line: 4 }, + end: { column: 19, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [142, 143], + loc: { + start: { column: 19, line: 4 }, + end: { column: 20, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [144, 145], + loc: { + start: { column: 21, line: 4 }, + end: { column: 22, line: 4 }, + }, + }, + Identifier { + type: "Identifier", + value: "assert", + + range: [146, 152], + loc: { + start: { column: 23, line: 4 }, + end: { column: 29, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [152, 153], + loc: { + start: { column: 29, line: 4 }, + end: { column: 30, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [154, 155], + loc: { + start: { column: 31, line: 4 }, + end: { column: 32, line: 4 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [156, 160], + loc: { + start: { column: 33, line: 4 }, + end: { column: 37, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [160, 161], + loc: { + start: { column: 37, line: 4 }, + end: { column: 38, line: 4 }, + }, + }, + String { + type: "String", + value: ""json"", + + range: [162, 168], + loc: { + start: { column: 39, line: 4 }, + end: { column: 45, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [169, 170], + loc: { + start: { column: 46, line: 4 }, + end: { column: 47, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [171, 172], + loc: { + start: { column: 48, line: 4 }, + end: { column: 49, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [172, 173], + loc: { + start: { column: 49, line: 4 }, + end: { column: 50, line: 4 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [173, 174], + loc: { + start: { column: 50, line: 4 }, + end: { column: 51, line: 4 }, + }, + }, ] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/5-AST-Alignment-AST.shot index 5104c088e48f..19141570cdb3 100644 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/5-AST-Alignment-AST.shot @@ -150,12 +150,154 @@ Snapshot Diff: end: { column: 49, line: 3 }, }, }, + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'B', +- optional: false, + + range: [128, 129], + loc: { + start: { column: 5, line: 4 }, + end: { column: 6, line: 4 }, + }, + }, + typeAnnotation: TSImportType { + type: 'TSImportType', +- argument: TSLiteralType { +- type: 'TSLiteralType', +- literal: Literal { +- type: 'Literal', +- raw: '"B"', +- value: 'B', +- +- range: [139, 142], +- loc: { +- start: { column: 16, line: 4 }, +- end: { column: 19, line: 4 }, +- }, +- }, ++ argument: Literal { ++ type: 'Literal', ++ raw: '"B"', ++ value: 'B', + + range: [139, 142], + loc: { + start: { column: 16, line: 4 }, + end: { column: 19, line: 4 }, + }, + }, + options: ObjectExpression { + type: 'ObjectExpression', + properties: Array [ + Property { + type: 'Property', + computed: false, + key: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'assert', +- optional: false, + + range: [146, 152], + loc: { + start: { column: 23, line: 4 }, + end: { column: 29, line: 4 }, + }, + }, + kind: 'init', + method: false, +- optional: false, + shorthand: false, + value: ObjectExpression { + type: 'ObjectExpression', + properties: Array [ + Property { + type: 'Property', + computed: false, + key: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'type', +- optional: false, + + range: [156, 160], + loc: { + start: { column: 33, line: 4 }, + end: { column: 37, line: 4 }, + }, + }, + kind: 'init', + method: false, +- optional: false, + shorthand: false, + value: Literal { + type: 'Literal', + raw: '"json"', + value: 'json', + + range: [162, 168], + loc: { + start: { column: 39, line: 4 }, + end: { column: 45, line: 4 }, + }, + }, + + range: [156, 168], + loc: { + start: { column: 33, line: 4 }, + end: { column: 45, line: 4 }, + }, + }, + ], + + range: [154, 170], + loc: { + start: { column: 31, line: 4 }, + end: { column: 47, line: 4 }, + }, + }, + + range: [146, 170], + loc: { + start: { column: 23, line: 4 }, + end: { column: 47, line: 4 }, + }, + }, + ], + + range: [144, 172], + loc: { + start: { column: 21, line: 4 }, + end: { column: 49, line: 4 }, + }, + }, +- qualifier: null, +- typeArguments: null, + + range: [132, 173], + loc: { + start: { column: 9, line: 4 }, + end: { column: 50, line: 4 }, + }, + }, + + range: [123, 174], + loc: { + start: { column: 0, line: 4 }, + end: { column: 51, line: 4 }, + }, + }, ], sourceType: 'script', - range: [73, 123], + range: [73, 175], loc: { start: { column: 0, line: 3 }, - end: { column: 0, line: 4 }, + end: { column: 0, line: 5 }, }, } diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/6-AST-Alignment-Tokens.shot index 3e9b0aba183a..515b40d7503a 100644 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/6-AST-Alignment-Tokens.shot @@ -188,4 +188,184 @@ Snapshot Diff: end: { column: 49, line: 3 }, }, }, + Identifier { + type: 'Identifier', + value: 'type', + + range: [123, 127], + loc: { + start: { column: 0, line: 4 }, + end: { column: 4, line: 4 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'B', + + range: [128, 129], + loc: { + start: { column: 5, line: 4 }, + end: { column: 6, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '=', + + range: [130, 131], + loc: { + start: { column: 7, line: 4 }, + end: { column: 8, line: 4 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'import', + + range: [132, 138], + loc: { + start: { column: 9, line: 4 }, + end: { column: 15, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '(', + + range: [138, 139], + loc: { + start: { column: 15, line: 4 }, + end: { column: 16, line: 4 }, + }, + }, + String { + type: 'String', + value: '"B"', + + range: [139, 142], + loc: { + start: { column: 16, line: 4 }, + end: { column: 19, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [142, 143], + loc: { + start: { column: 19, line: 4 }, + end: { column: 20, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [144, 145], + loc: { + start: { column: 21, line: 4 }, + end: { column: 22, line: 4 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'assert', + + range: [146, 152], + loc: { + start: { column: 23, line: 4 }, + end: { column: 29, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ':', + + range: [152, 153], + loc: { + start: { column: 29, line: 4 }, + end: { column: 30, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [154, 155], + loc: { + start: { column: 31, line: 4 }, + end: { column: 32, line: 4 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'type', + + range: [156, 160], + loc: { + start: { column: 33, line: 4 }, + end: { column: 37, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ':', + + range: [160, 161], + loc: { + start: { column: 37, line: 4 }, + end: { column: 38, line: 4 }, + }, + }, + String { + type: 'String', + value: '"json"', + + range: [162, 168], + loc: { + start: { column: 39, line: 4 }, + end: { column: 45, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [169, 170], + loc: { + start: { column: 46, line: 4 }, + end: { column: 47, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [171, 172], + loc: { + start: { column: 48, line: 4 }, + end: { column: 49, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ')', + + range: [172, 173], + loc: { + start: { column: 49, line: 4 }, + end: { column: 50, line: 4 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [173, 174], + loc: { + start: { column: 50, line: 4 }, + end: { column: 51, line: 4 }, + }, + }, ] diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 7faa5353b12c..8c2055a591be 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -3118,8 +3118,13 @@ export class Converter { node, this.ast, )!; - const withToken = findNextToken(openBraceToken, node, this.ast)!; - const withTokenRange = getRange(withToken, this.ast); + const withOrAssertToken = findNextToken( + openBraceToken, + node, + this.ast, + )!; + const withOrAssertTokenRange = getRange(withOrAssertToken, this.ast); + const withOrAssertName = withOrAssertToken.getText(); options = this.createNode(node, { type: AST_NODE_TYPES.ObjectExpression, @@ -3127,13 +3132,13 @@ export class Converter { properties: [ this.createNode(node, { type: AST_NODE_TYPES.Property, - range: [withTokenRange[0], node.attributes.end], + range: [withOrAssertTokenRange[0], node.attributes.end], computed: false, key: this.createNode(node, { type: AST_NODE_TYPES.Identifier, - range: withTokenRange, + range: withOrAssertTokenRange, decorators: [], - name: 'with', + name: withOrAssertName, optional: false, typeAnnotation: undefined, }), From 725831a58638ec62d0316db26d2a80e7e883639c Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Fri, 2 May 2025 22:34:30 +0100 Subject: [PATCH 2/3] Amend fixtures --- .prettierignore | 3 +- .../fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 150 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 182 +++++++++ .../snapshots/3-Babel-AST.shot | 130 ++++++ .../snapshots/4-Babel-Tokens.shot | 182 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 161 ++++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 5 + .../fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 150 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 182 +++++++++ .../snapshots/3-Babel-AST.shot | 130 ++++++ .../snapshots/4-Babel-Tokens.shot | 182 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 161 ++++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 191 +++++++++ .../fixture.ts | 4 - .../snapshots/1-TSESTree-AST.shot | 288 -------------- .../snapshots/2-TSESTree-Tokens.shot | 362 ----------------- .../snapshots/3-Babel-AST.shot | 248 ------------ .../snapshots/4-Babel-Tokens.shot | 362 ----------------- .../snapshots/5-AST-Alignment-AST.shot | 303 -------------- .../snapshots/6-AST-Alignment-Tokens.shot | 371 ------------------ .../tests/fixtures-with-differences-ast.shot | 3 +- .../fixtures-with-differences-tokens.shot | 2 +- 24 files changed, 1813 insertions(+), 1941 deletions(-) create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/fixture.ts create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/fixture.ts create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/6-AST-Alignment-Tokens.shot delete mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts delete mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/1-TSESTree-AST.shot delete mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/2-TSESTree-Tokens.shot delete mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/3-Babel-AST.shot delete mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/4-Babel-Tokens.shot delete mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/5-AST-Alignment-AST.shot delete mode 100644 packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/6-AST-Alignment-Tokens.shot diff --git a/.prettierignore b/.prettierignore index 7bc0cafd73df..500bc3eaf91a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -26,7 +26,8 @@ packages/ast-spec/src/special/ExportSpecifier/fixtures/value-export-specifier/fi # TODO - remove this once prettier supports it # https://github.com/prettier/prettier/issues/16072 -packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts +packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/fixture.ts +packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/fixture.ts # Ignore CHANGELOG.md files to avoid issues with automated release job CHANGELOG.md diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/fixture.ts b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/fixture.ts new file mode 100644 index 000000000000..6fc4ddf6f17b --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/fixture.ts @@ -0,0 +1 @@ +type A = import("A", { assert: { type: "json" } }); diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..7c61c4266eca --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,150 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "A", + optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSImportType { + type: "TSImportType", + argument: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: ""A"", + value: "A", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + options: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "assert", + optional: false, + + range: [23, 29], + loc: { + start: { column: 23, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + kind: "init", + method: false, + optional: false, + shorthand: false, + value: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "type", + optional: false, + + range: [33, 37], + loc: { + start: { column: 33, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + kind: "init", + method: false, + optional: false, + shorthand: false, + value: Literal { + type: "Literal", + raw: ""json"", + value: "json", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [33, 45], + loc: { + start: { column: 33, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + + range: [31, 47], + loc: { + start: { column: 31, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + + range: [23, 47], + loc: { + start: { column: 23, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + ], + + range: [21, 49], + loc: { + start: { column: 21, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + qualifier: null, + typeArguments: null, + + range: [9, 50], + loc: { + start: { column: 9, line: 1 }, + end: { column: 50, line: 1 }, + }, + }, + + range: [0, 51], + loc: { + start: { column: 0, line: 1 }, + end: { column: 51, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 52], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..22e664bd59cb --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,182 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "import", + + range: [9, 15], + loc: { + start: { column: 9, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + String { + type: "String", + value: ""A"", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "assert", + + range: [23, 29], + loc: { + start: { column: 23, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [33, 37], + loc: { + start: { column: 33, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [37, 38], + loc: { + start: { column: 37, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + String { + type: "String", + value: ""json"", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [48, 49], + loc: { + start: { column: 48, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [49, 50], + loc: { + start: { column: 49, line: 1 }, + end: { column: 50, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [50, 51], + loc: { + start: { column: 50, line: 1 }, + end: { column: 51, line: 1 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..f78138e8ff75 --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/3-Babel-AST.shot @@ -0,0 +1,130 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "A", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSImportType { + type: "TSImportType", + argument: Literal { + type: "Literal", + raw: ""A"", + value: "A", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + options: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + name: "assert", + + range: [23, 29], + loc: { + start: { column: 23, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + kind: "init", + method: false, + shorthand: false, + value: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + name: "type", + + range: [33, 37], + loc: { + start: { column: 33, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + kind: "init", + method: false, + shorthand: false, + value: Literal { + type: "Literal", + raw: ""json"", + value: "json", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [33, 45], + loc: { + start: { column: 33, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + + range: [31, 47], + loc: { + start: { column: 31, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + + range: [23, 47], + loc: { + start: { column: 23, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + ], + + range: [21, 49], + loc: { + start: { column: 21, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + + range: [9, 50], + loc: { + start: { column: 9, line: 1 }, + end: { column: 50, line: 1 }, + }, + }, + + range: [0, 51], + loc: { + start: { column: 0, line: 1 }, + end: { column: 51, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 52], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..22e664bd59cb --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,182 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "import", + + range: [9, 15], + loc: { + start: { column: 9, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + String { + type: "String", + value: ""A"", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "assert", + + range: [23, 29], + loc: { + start: { column: 23, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [33, 37], + loc: { + start: { column: 33, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [37, 38], + loc: { + start: { column: 37, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + String { + type: "String", + value: ""json"", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [48, 49], + loc: { + start: { column: 48, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [49, 50], + loc: { + start: { column: 49, line: 1 }, + end: { column: 50, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [50, 51], + loc: { + start: { column: 50, line: 1 }, + end: { column: 51, line: 1 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..9fdb8dfce2ad --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,161 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSImportType > type-import-type-with-import-attributes-assert > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'A', +- optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSImportType { + type: 'TSImportType', +- argument: TSLiteralType { +- type: 'TSLiteralType', +- literal: Literal { +- type: 'Literal', +- raw: '"A"', +- value: 'A', +- +- range: [16, 19], +- loc: { +- start: { column: 16, line: 1 }, +- end: { column: 19, line: 1 }, +- }, +- }, ++ argument: Literal { ++ type: 'Literal', ++ raw: '"A"', ++ value: 'A', + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + options: ObjectExpression { + type: 'ObjectExpression', + properties: Array [ + Property { + type: 'Property', + computed: false, + key: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'assert', +- optional: false, + + range: [23, 29], + loc: { + start: { column: 23, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + kind: 'init', + method: false, +- optional: false, + shorthand: false, + value: ObjectExpression { + type: 'ObjectExpression', + properties: Array [ + Property { + type: 'Property', + computed: false, + key: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'type', +- optional: false, + + range: [33, 37], + loc: { + start: { column: 33, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + kind: 'init', + method: false, +- optional: false, + shorthand: false, + value: Literal { + type: 'Literal', + raw: '"json"', + value: 'json', + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [33, 45], + loc: { + start: { column: 33, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + + range: [31, 47], + loc: { + start: { column: 31, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + + range: [23, 47], + loc: { + start: { column: 23, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + ], + + range: [21, 49], + loc: { + start: { column: 21, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, +- qualifier: null, +- typeArguments: null, + + range: [9, 50], + loc: { + start: { column: 9, line: 1 }, + end: { column: 50, line: 1 }, + }, + }, + + range: [0, 51], + loc: { + start: { column: 0, line: 1 }, + end: { column: 51, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 52], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + } diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..17d52dcc5779 --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,5 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSImportType > type-import-type-with-import-attributes-assert > AST Alignment - Token`] +Snapshot Diff: +Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/fixture.ts b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/fixture.ts new file mode 100644 index 000000000000..79df9dadf881 --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/fixture.ts @@ -0,0 +1 @@ +type A = import("A", { with: { type: "json" } }); diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..225e77e8303a --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,150 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "A", + optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSImportType { + type: "TSImportType", + argument: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: ""A"", + value: "A", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + options: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "with", + optional: false, + + range: [23, 27], + loc: { + start: { column: 23, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + kind: "init", + method: false, + optional: false, + shorthand: false, + value: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + decorators: [], + name: "type", + optional: false, + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + kind: "init", + method: false, + optional: false, + shorthand: false, + value: Literal { + type: "Literal", + raw: ""json"", + value: "json", + + range: [37, 43], + loc: { + start: { column: 37, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + + range: [31, 43], + loc: { + start: { column: 31, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + ], + + range: [29, 45], + loc: { + start: { column: 29, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [23, 45], + loc: { + start: { column: 23, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + + range: [21, 47], + loc: { + start: { column: 21, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + qualifier: null, + typeArguments: null, + + range: [9, 48], + loc: { + start: { column: 9, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 50], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..d9a618899217 --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,182 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "import", + + range: [9, 15], + loc: { + start: { column: 9, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + String { + type: "String", + value: ""A"", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "with", + + range: [23, 27], + loc: { + start: { column: 23, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [35, 36], + loc: { + start: { column: 35, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + String { + type: "String", + value: ""json"", + + range: [37, 43], + loc: { + start: { column: 37, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [44, 45], + loc: { + start: { column: 44, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [48, 49], + loc: { + start: { column: 48, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..ba58021ce28e --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/3-Babel-AST.shot @@ -0,0 +1,130 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "A", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSImportType { + type: "TSImportType", + argument: Literal { + type: "Literal", + raw: ""A"", + value: "A", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + options: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + name: "with", + + range: [23, 27], + loc: { + start: { column: 23, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + kind: "init", + method: false, + shorthand: false, + value: ObjectExpression { + type: "ObjectExpression", + properties: [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + name: "type", + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + kind: "init", + method: false, + shorthand: false, + value: Literal { + type: "Literal", + raw: ""json"", + value: "json", + + range: [37, 43], + loc: { + start: { column: 37, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + + range: [31, 43], + loc: { + start: { column: 31, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + ], + + range: [29, 45], + loc: { + start: { column: 29, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [23, 45], + loc: { + start: { column: 23, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + + range: [21, 47], + loc: { + start: { column: 21, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + + range: [9, 48], + loc: { + start: { column: 9, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 50], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..91cd1f711197 --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,182 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "import", + + range: [9, 15], + loc: { + start: { column: 9, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + String { + type: "String", + value: ""A"", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "with", + + range: [23, 27], + loc: { + start: { column: 23, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [35, 36], + loc: { + start: { column: 35, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + String { + type: "String", + value: ""json"", + + range: [37, 43], + loc: { + start: { column: 37, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [44, 45], + loc: { + start: { column: 44, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [48, 49], + loc: { + start: { column: 48, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..be699cfe3e1d --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,161 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSImportType > type-import-type-with-import-attributes-with > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'A', +- optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSImportType { + type: 'TSImportType', +- argument: TSLiteralType { +- type: 'TSLiteralType', +- literal: Literal { +- type: 'Literal', +- raw: '"A"', +- value: 'A', +- +- range: [16, 19], +- loc: { +- start: { column: 16, line: 1 }, +- end: { column: 19, line: 1 }, +- }, +- }, ++ argument: Literal { ++ type: 'Literal', ++ raw: '"A"', ++ value: 'A', + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + options: ObjectExpression { + type: 'ObjectExpression', + properties: Array [ + Property { + type: 'Property', + computed: false, + key: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'with', +- optional: false, + + range: [23, 27], + loc: { + start: { column: 23, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + kind: 'init', + method: false, +- optional: false, + shorthand: false, + value: ObjectExpression { + type: 'ObjectExpression', + properties: Array [ + Property { + type: 'Property', + computed: false, + key: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'type', +- optional: false, + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + kind: 'init', + method: false, +- optional: false, + shorthand: false, + value: Literal { + type: 'Literal', + raw: '"json"', + value: 'json', + + range: [37, 43], + loc: { + start: { column: 37, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + + range: [31, 43], + loc: { + start: { column: 31, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + ], + + range: [29, 45], + loc: { + start: { column: 29, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [23, 45], + loc: { + start: { column: 23, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + + range: [21, 47], + loc: { + start: { column: 21, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, +- qualifier: null, +- typeArguments: null, + + range: [9, 48], + loc: { + start: { column: 9, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 50], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + } diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..87fdac962d79 --- /dev/null +++ b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes-with/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,191 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSImportType > type-import-type-with-import-attributes-with > AST Alignment - Token`] +Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Identifier { + type: 'Identifier', + value: 'type', + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'A', + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '=', + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'import', + + range: [9, 15], + loc: { + start: { column: 9, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '(', + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + String { + type: 'String', + value: '"A"', + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'with', + + range: [23, 27], + loc: { + start: { column: 23, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ':', + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'type', + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ':', + + range: [35, 36], + loc: { + start: { column: 35, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + String { + type: 'String', + value: '"json"', + + range: [37, 43], + loc: { + start: { column: 37, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [44, 45], + loc: { + start: { column: 44, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ')', + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [48, 49], + loc: { + start: { column: 48, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + ] diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts deleted file mode 100644 index 1eeabf2f219b..000000000000 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts +++ /dev/null @@ -1,4 +0,0 @@ -// TODO: This fixture might be too large, and if so should be split up. - -type A = import("A", { with: { type: "json" } }); -type B = import("B", { assert: { type: "json" } }); diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/1-TSESTree-AST.shot deleted file mode 100644 index 332768d18143..000000000000 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/1-TSESTree-AST.shot +++ /dev/null @@ -1,288 +0,0 @@ -Program { - type: "Program", - body: [ - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - declare: false, - id: Identifier { - type: "Identifier", - decorators: [], - name: "A", - optional: false, - - range: [78, 79], - loc: { - start: { column: 5, line: 3 }, - end: { column: 6, line: 3 }, - }, - }, - typeAnnotation: TSImportType { - type: "TSImportType", - argument: TSLiteralType { - type: "TSLiteralType", - literal: Literal { - type: "Literal", - raw: ""A"", - value: "A", - - range: [89, 92], - loc: { - start: { column: 16, line: 3 }, - end: { column: 19, line: 3 }, - }, - }, - - range: [89, 92], - loc: { - start: { column: 16, line: 3 }, - end: { column: 19, line: 3 }, - }, - }, - options: ObjectExpression { - type: "ObjectExpression", - properties: [ - Property { - type: "Property", - computed: false, - key: Identifier { - type: "Identifier", - decorators: [], - name: "with", - optional: false, - - range: [96, 100], - loc: { - start: { column: 23, line: 3 }, - end: { column: 27, line: 3 }, - }, - }, - kind: "init", - method: false, - optional: false, - shorthand: false, - value: ObjectExpression { - type: "ObjectExpression", - properties: [ - Property { - type: "Property", - computed: false, - key: Identifier { - type: "Identifier", - decorators: [], - name: "type", - optional: false, - - range: [104, 108], - loc: { - start: { column: 31, line: 3 }, - end: { column: 35, line: 3 }, - }, - }, - kind: "init", - method: false, - optional: false, - shorthand: false, - value: Literal { - type: "Literal", - raw: ""json"", - value: "json", - - range: [110, 116], - loc: { - start: { column: 37, line: 3 }, - end: { column: 43, line: 3 }, - }, - }, - - range: [104, 116], - loc: { - start: { column: 31, line: 3 }, - end: { column: 43, line: 3 }, - }, - }, - ], - - range: [102, 118], - loc: { - start: { column: 29, line: 3 }, - end: { column: 45, line: 3 }, - }, - }, - - range: [96, 118], - loc: { - start: { column: 23, line: 3 }, - end: { column: 45, line: 3 }, - }, - }, - ], - - range: [94, 120], - loc: { - start: { column: 21, line: 3 }, - end: { column: 47, line: 3 }, - }, - }, - qualifier: null, - typeArguments: null, - - range: [82, 121], - loc: { - start: { column: 9, line: 3 }, - end: { column: 48, line: 3 }, - }, - }, - - range: [73, 122], - loc: { - start: { column: 0, line: 3 }, - end: { column: 49, line: 3 }, - }, - }, - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - declare: false, - id: Identifier { - type: "Identifier", - decorators: [], - name: "B", - optional: false, - - range: [128, 129], - loc: { - start: { column: 5, line: 4 }, - end: { column: 6, line: 4 }, - }, - }, - typeAnnotation: TSImportType { - type: "TSImportType", - argument: TSLiteralType { - type: "TSLiteralType", - literal: Literal { - type: "Literal", - raw: ""B"", - value: "B", - - range: [139, 142], - loc: { - start: { column: 16, line: 4 }, - end: { column: 19, line: 4 }, - }, - }, - - range: [139, 142], - loc: { - start: { column: 16, line: 4 }, - end: { column: 19, line: 4 }, - }, - }, - options: ObjectExpression { - type: "ObjectExpression", - properties: [ - Property { - type: "Property", - computed: false, - key: Identifier { - type: "Identifier", - decorators: [], - name: "assert", - optional: false, - - range: [146, 152], - loc: { - start: { column: 23, line: 4 }, - end: { column: 29, line: 4 }, - }, - }, - kind: "init", - method: false, - optional: false, - shorthand: false, - value: ObjectExpression { - type: "ObjectExpression", - properties: [ - Property { - type: "Property", - computed: false, - key: Identifier { - type: "Identifier", - decorators: [], - name: "type", - optional: false, - - range: [156, 160], - loc: { - start: { column: 33, line: 4 }, - end: { column: 37, line: 4 }, - }, - }, - kind: "init", - method: false, - optional: false, - shorthand: false, - value: Literal { - type: "Literal", - raw: ""json"", - value: "json", - - range: [162, 168], - loc: { - start: { column: 39, line: 4 }, - end: { column: 45, line: 4 }, - }, - }, - - range: [156, 168], - loc: { - start: { column: 33, line: 4 }, - end: { column: 45, line: 4 }, - }, - }, - ], - - range: [154, 170], - loc: { - start: { column: 31, line: 4 }, - end: { column: 47, line: 4 }, - }, - }, - - range: [146, 170], - loc: { - start: { column: 23, line: 4 }, - end: { column: 47, line: 4 }, - }, - }, - ], - - range: [144, 172], - loc: { - start: { column: 21, line: 4 }, - end: { column: 49, line: 4 }, - }, - }, - qualifier: null, - typeArguments: null, - - range: [132, 173], - loc: { - start: { column: 9, line: 4 }, - end: { column: 50, line: 4 }, - }, - }, - - range: [123, 174], - loc: { - start: { column: 0, line: 4 }, - end: { column: 51, line: 4 }, - }, - }, - ], - sourceType: "script", - - range: [73, 175], - loc: { - start: { column: 0, line: 3 }, - end: { column: 0, line: 5 }, - }, -} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/2-TSESTree-Tokens.shot deleted file mode 100644 index 3a98006b3e92..000000000000 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/2-TSESTree-Tokens.shot +++ /dev/null @@ -1,362 +0,0 @@ -[ - Identifier { - type: "Identifier", - value: "type", - - range: [73, 77], - loc: { - start: { column: 0, line: 3 }, - end: { column: 4, line: 3 }, - }, - }, - Identifier { - type: "Identifier", - value: "A", - - range: [78, 79], - loc: { - start: { column: 5, line: 3 }, - end: { column: 6, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "=", - - range: [80, 81], - loc: { - start: { column: 7, line: 3 }, - end: { column: 8, line: 3 }, - }, - }, - Keyword { - type: "Keyword", - value: "import", - - range: [82, 88], - loc: { - start: { column: 9, line: 3 }, - end: { column: 15, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "(", - - range: [88, 89], - loc: { - start: { column: 15, line: 3 }, - end: { column: 16, line: 3 }, - }, - }, - String { - type: "String", - value: ""A"", - - range: [89, 92], - loc: { - start: { column: 16, line: 3 }, - end: { column: 19, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ",", - - range: [92, 93], - loc: { - start: { column: 19, line: 3 }, - end: { column: 20, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [94, 95], - loc: { - start: { column: 21, line: 3 }, - end: { column: 22, line: 3 }, - }, - }, - Keyword { - type: "Keyword", - value: "with", - - range: [96, 100], - loc: { - start: { column: 23, line: 3 }, - end: { column: 27, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [100, 101], - loc: { - start: { column: 27, line: 3 }, - end: { column: 28, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [102, 103], - loc: { - start: { column: 29, line: 3 }, - end: { column: 30, line: 3 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [104, 108], - loc: { - start: { column: 31, line: 3 }, - end: { column: 35, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [108, 109], - loc: { - start: { column: 35, line: 3 }, - end: { column: 36, line: 3 }, - }, - }, - String { - type: "String", - value: ""json"", - - range: [110, 116], - loc: { - start: { column: 37, line: 3 }, - end: { column: 43, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [117, 118], - loc: { - start: { column: 44, line: 3 }, - end: { column: 45, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [119, 120], - loc: { - start: { column: 46, line: 3 }, - end: { column: 47, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ")", - - range: [120, 121], - loc: { - start: { column: 47, line: 3 }, - end: { column: 48, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [121, 122], - loc: { - start: { column: 48, line: 3 }, - end: { column: 49, line: 3 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [123, 127], - loc: { - start: { column: 0, line: 4 }, - end: { column: 4, line: 4 }, - }, - }, - Identifier { - type: "Identifier", - value: "B", - - range: [128, 129], - loc: { - start: { column: 5, line: 4 }, - end: { column: 6, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "=", - - range: [130, 131], - loc: { - start: { column: 7, line: 4 }, - end: { column: 8, line: 4 }, - }, - }, - Keyword { - type: "Keyword", - value: "import", - - range: [132, 138], - loc: { - start: { column: 9, line: 4 }, - end: { column: 15, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "(", - - range: [138, 139], - loc: { - start: { column: 15, line: 4 }, - end: { column: 16, line: 4 }, - }, - }, - String { - type: "String", - value: ""B"", - - range: [139, 142], - loc: { - start: { column: 16, line: 4 }, - end: { column: 19, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ",", - - range: [142, 143], - loc: { - start: { column: 19, line: 4 }, - end: { column: 20, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [144, 145], - loc: { - start: { column: 21, line: 4 }, - end: { column: 22, line: 4 }, - }, - }, - Identifier { - type: "Identifier", - value: "assert", - - range: [146, 152], - loc: { - start: { column: 23, line: 4 }, - end: { column: 29, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [152, 153], - loc: { - start: { column: 29, line: 4 }, - end: { column: 30, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [154, 155], - loc: { - start: { column: 31, line: 4 }, - end: { column: 32, line: 4 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [156, 160], - loc: { - start: { column: 33, line: 4 }, - end: { column: 37, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [160, 161], - loc: { - start: { column: 37, line: 4 }, - end: { column: 38, line: 4 }, - }, - }, - String { - type: "String", - value: ""json"", - - range: [162, 168], - loc: { - start: { column: 39, line: 4 }, - end: { column: 45, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [169, 170], - loc: { - start: { column: 46, line: 4 }, - end: { column: 47, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [171, 172], - loc: { - start: { column: 48, line: 4 }, - end: { column: 49, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ")", - - range: [172, 173], - loc: { - start: { column: 49, line: 4 }, - end: { column: 50, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [173, 174], - loc: { - start: { column: 50, line: 4 }, - end: { column: 51, line: 4 }, - }, - }, -] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/3-Babel-AST.shot deleted file mode 100644 index 3de9ec6dd13f..000000000000 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/3-Babel-AST.shot +++ /dev/null @@ -1,248 +0,0 @@ -Program { - type: "Program", - body: [ - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - id: Identifier { - type: "Identifier", - name: "A", - - range: [78, 79], - loc: { - start: { column: 5, line: 3 }, - end: { column: 6, line: 3 }, - }, - }, - typeAnnotation: TSImportType { - type: "TSImportType", - argument: Literal { - type: "Literal", - raw: ""A"", - value: "A", - - range: [89, 92], - loc: { - start: { column: 16, line: 3 }, - end: { column: 19, line: 3 }, - }, - }, - options: ObjectExpression { - type: "ObjectExpression", - properties: [ - Property { - type: "Property", - computed: false, - key: Identifier { - type: "Identifier", - name: "with", - - range: [96, 100], - loc: { - start: { column: 23, line: 3 }, - end: { column: 27, line: 3 }, - }, - }, - kind: "init", - method: false, - shorthand: false, - value: ObjectExpression { - type: "ObjectExpression", - properties: [ - Property { - type: "Property", - computed: false, - key: Identifier { - type: "Identifier", - name: "type", - - range: [104, 108], - loc: { - start: { column: 31, line: 3 }, - end: { column: 35, line: 3 }, - }, - }, - kind: "init", - method: false, - shorthand: false, - value: Literal { - type: "Literal", - raw: ""json"", - value: "json", - - range: [110, 116], - loc: { - start: { column: 37, line: 3 }, - end: { column: 43, line: 3 }, - }, - }, - - range: [104, 116], - loc: { - start: { column: 31, line: 3 }, - end: { column: 43, line: 3 }, - }, - }, - ], - - range: [102, 118], - loc: { - start: { column: 29, line: 3 }, - end: { column: 45, line: 3 }, - }, - }, - - range: [96, 118], - loc: { - start: { column: 23, line: 3 }, - end: { column: 45, line: 3 }, - }, - }, - ], - - range: [94, 120], - loc: { - start: { column: 21, line: 3 }, - end: { column: 47, line: 3 }, - }, - }, - - range: [82, 121], - loc: { - start: { column: 9, line: 3 }, - end: { column: 48, line: 3 }, - }, - }, - - range: [73, 122], - loc: { - start: { column: 0, line: 3 }, - end: { column: 49, line: 3 }, - }, - }, - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - id: Identifier { - type: "Identifier", - name: "B", - - range: [128, 129], - loc: { - start: { column: 5, line: 4 }, - end: { column: 6, line: 4 }, - }, - }, - typeAnnotation: TSImportType { - type: "TSImportType", - argument: Literal { - type: "Literal", - raw: ""B"", - value: "B", - - range: [139, 142], - loc: { - start: { column: 16, line: 4 }, - end: { column: 19, line: 4 }, - }, - }, - options: ObjectExpression { - type: "ObjectExpression", - properties: [ - Property { - type: "Property", - computed: false, - key: Identifier { - type: "Identifier", - name: "assert", - - range: [146, 152], - loc: { - start: { column: 23, line: 4 }, - end: { column: 29, line: 4 }, - }, - }, - kind: "init", - method: false, - shorthand: false, - value: ObjectExpression { - type: "ObjectExpression", - properties: [ - Property { - type: "Property", - computed: false, - key: Identifier { - type: "Identifier", - name: "type", - - range: [156, 160], - loc: { - start: { column: 33, line: 4 }, - end: { column: 37, line: 4 }, - }, - }, - kind: "init", - method: false, - shorthand: false, - value: Literal { - type: "Literal", - raw: ""json"", - value: "json", - - range: [162, 168], - loc: { - start: { column: 39, line: 4 }, - end: { column: 45, line: 4 }, - }, - }, - - range: [156, 168], - loc: { - start: { column: 33, line: 4 }, - end: { column: 45, line: 4 }, - }, - }, - ], - - range: [154, 170], - loc: { - start: { column: 31, line: 4 }, - end: { column: 47, line: 4 }, - }, - }, - - range: [146, 170], - loc: { - start: { column: 23, line: 4 }, - end: { column: 47, line: 4 }, - }, - }, - ], - - range: [144, 172], - loc: { - start: { column: 21, line: 4 }, - end: { column: 49, line: 4 }, - }, - }, - - range: [132, 173], - loc: { - start: { column: 9, line: 4 }, - end: { column: 50, line: 4 }, - }, - }, - - range: [123, 174], - loc: { - start: { column: 0, line: 4 }, - end: { column: 51, line: 4 }, - }, - }, - ], - sourceType: "script", - - range: [73, 175], - loc: { - start: { column: 0, line: 3 }, - end: { column: 0, line: 5 }, - }, -} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/4-Babel-Tokens.shot deleted file mode 100644 index 102f865c6a01..000000000000 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/4-Babel-Tokens.shot +++ /dev/null @@ -1,362 +0,0 @@ -[ - Identifier { - type: "Identifier", - value: "type", - - range: [73, 77], - loc: { - start: { column: 0, line: 3 }, - end: { column: 4, line: 3 }, - }, - }, - Identifier { - type: "Identifier", - value: "A", - - range: [78, 79], - loc: { - start: { column: 5, line: 3 }, - end: { column: 6, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "=", - - range: [80, 81], - loc: { - start: { column: 7, line: 3 }, - end: { column: 8, line: 3 }, - }, - }, - Keyword { - type: "Keyword", - value: "import", - - range: [82, 88], - loc: { - start: { column: 9, line: 3 }, - end: { column: 15, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "(", - - range: [88, 89], - loc: { - start: { column: 15, line: 3 }, - end: { column: 16, line: 3 }, - }, - }, - String { - type: "String", - value: ""A"", - - range: [89, 92], - loc: { - start: { column: 16, line: 3 }, - end: { column: 19, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ",", - - range: [92, 93], - loc: { - start: { column: 19, line: 3 }, - end: { column: 20, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [94, 95], - loc: { - start: { column: 21, line: 3 }, - end: { column: 22, line: 3 }, - }, - }, - Identifier { - type: "Identifier", - value: "with", - - range: [96, 100], - loc: { - start: { column: 23, line: 3 }, - end: { column: 27, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [100, 101], - loc: { - start: { column: 27, line: 3 }, - end: { column: 28, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [102, 103], - loc: { - start: { column: 29, line: 3 }, - end: { column: 30, line: 3 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [104, 108], - loc: { - start: { column: 31, line: 3 }, - end: { column: 35, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [108, 109], - loc: { - start: { column: 35, line: 3 }, - end: { column: 36, line: 3 }, - }, - }, - String { - type: "String", - value: ""json"", - - range: [110, 116], - loc: { - start: { column: 37, line: 3 }, - end: { column: 43, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [117, 118], - loc: { - start: { column: 44, line: 3 }, - end: { column: 45, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [119, 120], - loc: { - start: { column: 46, line: 3 }, - end: { column: 47, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ")", - - range: [120, 121], - loc: { - start: { column: 47, line: 3 }, - end: { column: 48, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [121, 122], - loc: { - start: { column: 48, line: 3 }, - end: { column: 49, line: 3 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [123, 127], - loc: { - start: { column: 0, line: 4 }, - end: { column: 4, line: 4 }, - }, - }, - Identifier { - type: "Identifier", - value: "B", - - range: [128, 129], - loc: { - start: { column: 5, line: 4 }, - end: { column: 6, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "=", - - range: [130, 131], - loc: { - start: { column: 7, line: 4 }, - end: { column: 8, line: 4 }, - }, - }, - Keyword { - type: "Keyword", - value: "import", - - range: [132, 138], - loc: { - start: { column: 9, line: 4 }, - end: { column: 15, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "(", - - range: [138, 139], - loc: { - start: { column: 15, line: 4 }, - end: { column: 16, line: 4 }, - }, - }, - String { - type: "String", - value: ""B"", - - range: [139, 142], - loc: { - start: { column: 16, line: 4 }, - end: { column: 19, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ",", - - range: [142, 143], - loc: { - start: { column: 19, line: 4 }, - end: { column: 20, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [144, 145], - loc: { - start: { column: 21, line: 4 }, - end: { column: 22, line: 4 }, - }, - }, - Identifier { - type: "Identifier", - value: "assert", - - range: [146, 152], - loc: { - start: { column: 23, line: 4 }, - end: { column: 29, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [152, 153], - loc: { - start: { column: 29, line: 4 }, - end: { column: 30, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [154, 155], - loc: { - start: { column: 31, line: 4 }, - end: { column: 32, line: 4 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [156, 160], - loc: { - start: { column: 33, line: 4 }, - end: { column: 37, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [160, 161], - loc: { - start: { column: 37, line: 4 }, - end: { column: 38, line: 4 }, - }, - }, - String { - type: "String", - value: ""json"", - - range: [162, 168], - loc: { - start: { column: 39, line: 4 }, - end: { column: 45, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [169, 170], - loc: { - start: { column: 46, line: 4 }, - end: { column: 47, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [171, 172], - loc: { - start: { column: 48, line: 4 }, - end: { column: 49, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ")", - - range: [172, 173], - loc: { - start: { column: 49, line: 4 }, - end: { column: 50, line: 4 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [173, 174], - loc: { - start: { column: 50, line: 4 }, - end: { column: 51, line: 4 }, - }, - }, -] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/5-AST-Alignment-AST.shot deleted file mode 100644 index 19141570cdb3..000000000000 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/5-AST-Alignment-AST.shot +++ /dev/null @@ -1,303 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`AST Fixtures > type > TSImportType > type-import-type-with-import-attributes > AST Alignment - AST`] -Snapshot Diff: -- TSESTree -+ Babel - - Program { - type: 'Program', - body: Array [ - TSTypeAliasDeclaration { - type: 'TSTypeAliasDeclaration', -- declare: false, - id: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'A', -- optional: false, - - range: [78, 79], - loc: { - start: { column: 5, line: 3 }, - end: { column: 6, line: 3 }, - }, - }, - typeAnnotation: TSImportType { - type: 'TSImportType', -- argument: TSLiteralType { -- type: 'TSLiteralType', -- literal: Literal { -- type: 'Literal', -- raw: '"A"', -- value: 'A', -- -- range: [89, 92], -- loc: { -- start: { column: 16, line: 3 }, -- end: { column: 19, line: 3 }, -- }, -- }, -+ argument: Literal { -+ type: 'Literal', -+ raw: '"A"', -+ value: 'A', - - range: [89, 92], - loc: { - start: { column: 16, line: 3 }, - end: { column: 19, line: 3 }, - }, - }, - options: ObjectExpression { - type: 'ObjectExpression', - properties: Array [ - Property { - type: 'Property', - computed: false, - key: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'with', -- optional: false, - - range: [96, 100], - loc: { - start: { column: 23, line: 3 }, - end: { column: 27, line: 3 }, - }, - }, - kind: 'init', - method: false, -- optional: false, - shorthand: false, - value: ObjectExpression { - type: 'ObjectExpression', - properties: Array [ - Property { - type: 'Property', - computed: false, - key: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'type', -- optional: false, - - range: [104, 108], - loc: { - start: { column: 31, line: 3 }, - end: { column: 35, line: 3 }, - }, - }, - kind: 'init', - method: false, -- optional: false, - shorthand: false, - value: Literal { - type: 'Literal', - raw: '"json"', - value: 'json', - - range: [110, 116], - loc: { - start: { column: 37, line: 3 }, - end: { column: 43, line: 3 }, - }, - }, - - range: [104, 116], - loc: { - start: { column: 31, line: 3 }, - end: { column: 43, line: 3 }, - }, - }, - ], - - range: [102, 118], - loc: { - start: { column: 29, line: 3 }, - end: { column: 45, line: 3 }, - }, - }, - - range: [96, 118], - loc: { - start: { column: 23, line: 3 }, - end: { column: 45, line: 3 }, - }, - }, - ], - - range: [94, 120], - loc: { - start: { column: 21, line: 3 }, - end: { column: 47, line: 3 }, - }, - }, -- qualifier: null, -- typeArguments: null, - - range: [82, 121], - loc: { - start: { column: 9, line: 3 }, - end: { column: 48, line: 3 }, - }, - }, - - range: [73, 122], - loc: { - start: { column: 0, line: 3 }, - end: { column: 49, line: 3 }, - }, - }, - TSTypeAliasDeclaration { - type: 'TSTypeAliasDeclaration', -- declare: false, - id: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'B', -- optional: false, - - range: [128, 129], - loc: { - start: { column: 5, line: 4 }, - end: { column: 6, line: 4 }, - }, - }, - typeAnnotation: TSImportType { - type: 'TSImportType', -- argument: TSLiteralType { -- type: 'TSLiteralType', -- literal: Literal { -- type: 'Literal', -- raw: '"B"', -- value: 'B', -- -- range: [139, 142], -- loc: { -- start: { column: 16, line: 4 }, -- end: { column: 19, line: 4 }, -- }, -- }, -+ argument: Literal { -+ type: 'Literal', -+ raw: '"B"', -+ value: 'B', - - range: [139, 142], - loc: { - start: { column: 16, line: 4 }, - end: { column: 19, line: 4 }, - }, - }, - options: ObjectExpression { - type: 'ObjectExpression', - properties: Array [ - Property { - type: 'Property', - computed: false, - key: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'assert', -- optional: false, - - range: [146, 152], - loc: { - start: { column: 23, line: 4 }, - end: { column: 29, line: 4 }, - }, - }, - kind: 'init', - method: false, -- optional: false, - shorthand: false, - value: ObjectExpression { - type: 'ObjectExpression', - properties: Array [ - Property { - type: 'Property', - computed: false, - key: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'type', -- optional: false, - - range: [156, 160], - loc: { - start: { column: 33, line: 4 }, - end: { column: 37, line: 4 }, - }, - }, - kind: 'init', - method: false, -- optional: false, - shorthand: false, - value: Literal { - type: 'Literal', - raw: '"json"', - value: 'json', - - range: [162, 168], - loc: { - start: { column: 39, line: 4 }, - end: { column: 45, line: 4 }, - }, - }, - - range: [156, 168], - loc: { - start: { column: 33, line: 4 }, - end: { column: 45, line: 4 }, - }, - }, - ], - - range: [154, 170], - loc: { - start: { column: 31, line: 4 }, - end: { column: 47, line: 4 }, - }, - }, - - range: [146, 170], - loc: { - start: { column: 23, line: 4 }, - end: { column: 47, line: 4 }, - }, - }, - ], - - range: [144, 172], - loc: { - start: { column: 21, line: 4 }, - end: { column: 49, line: 4 }, - }, - }, -- qualifier: null, -- typeArguments: null, - - range: [132, 173], - loc: { - start: { column: 9, line: 4 }, - end: { column: 50, line: 4 }, - }, - }, - - range: [123, 174], - loc: { - start: { column: 0, line: 4 }, - end: { column: 51, line: 4 }, - }, - }, - ], - sourceType: 'script', - - range: [73, 175], - loc: { - start: { column: 0, line: 3 }, - end: { column: 0, line: 5 }, - }, - } diff --git a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/6-AST-Alignment-Tokens.shot deleted file mode 100644 index 515b40d7503a..000000000000 --- a/packages/ast-spec/src/type/TSImportType/fixtures/type-import-type-with-import-attributes/snapshots/6-AST-Alignment-Tokens.shot +++ /dev/null @@ -1,371 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`AST Fixtures > type > TSImportType > type-import-type-with-import-attributes > AST Alignment - Token`] -Snapshot Diff: -- TSESTree -+ Babel - - Array [ - Identifier { - type: 'Identifier', - value: 'type', - - range: [73, 77], - loc: { - start: { column: 0, line: 3 }, - end: { column: 4, line: 3 }, - }, - }, - Identifier { - type: 'Identifier', - value: 'A', - - range: [78, 79], - loc: { - start: { column: 5, line: 3 }, - end: { column: 6, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '=', - - range: [80, 81], - loc: { - start: { column: 7, line: 3 }, - end: { column: 8, line: 3 }, - }, - }, - Keyword { - type: 'Keyword', - value: 'import', - - range: [82, 88], - loc: { - start: { column: 9, line: 3 }, - end: { column: 15, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '(', - - range: [88, 89], - loc: { - start: { column: 15, line: 3 }, - end: { column: 16, line: 3 }, - }, - }, - String { - type: 'String', - value: '"A"', - - range: [89, 92], - loc: { - start: { column: 16, line: 3 }, - end: { column: 19, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ',', - - range: [92, 93], - loc: { - start: { column: 19, line: 3 }, - end: { column: 20, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '{', - - range: [94, 95], - loc: { - start: { column: 21, line: 3 }, - end: { column: 22, line: 3 }, - }, - }, -- Keyword { -- type: 'Keyword', -+ Identifier { -+ type: 'Identifier', - value: 'with', - - range: [96, 100], - loc: { - start: { column: 23, line: 3 }, - end: { column: 27, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ':', - - range: [100, 101], - loc: { - start: { column: 27, line: 3 }, - end: { column: 28, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '{', - - range: [102, 103], - loc: { - start: { column: 29, line: 3 }, - end: { column: 30, line: 3 }, - }, - }, - Identifier { - type: 'Identifier', - value: 'type', - - range: [104, 108], - loc: { - start: { column: 31, line: 3 }, - end: { column: 35, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ':', - - range: [108, 109], - loc: { - start: { column: 35, line: 3 }, - end: { column: 36, line: 3 }, - }, - }, - String { - type: 'String', - value: '"json"', - - range: [110, 116], - loc: { - start: { column: 37, line: 3 }, - end: { column: 43, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '}', - - range: [117, 118], - loc: { - start: { column: 44, line: 3 }, - end: { column: 45, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '}', - - range: [119, 120], - loc: { - start: { column: 46, line: 3 }, - end: { column: 47, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ')', - - range: [120, 121], - loc: { - start: { column: 47, line: 3 }, - end: { column: 48, line: 3 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ';', - - range: [121, 122], - loc: { - start: { column: 48, line: 3 }, - end: { column: 49, line: 3 }, - }, - }, - Identifier { - type: 'Identifier', - value: 'type', - - range: [123, 127], - loc: { - start: { column: 0, line: 4 }, - end: { column: 4, line: 4 }, - }, - }, - Identifier { - type: 'Identifier', - value: 'B', - - range: [128, 129], - loc: { - start: { column: 5, line: 4 }, - end: { column: 6, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '=', - - range: [130, 131], - loc: { - start: { column: 7, line: 4 }, - end: { column: 8, line: 4 }, - }, - }, - Keyword { - type: 'Keyword', - value: 'import', - - range: [132, 138], - loc: { - start: { column: 9, line: 4 }, - end: { column: 15, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '(', - - range: [138, 139], - loc: { - start: { column: 15, line: 4 }, - end: { column: 16, line: 4 }, - }, - }, - String { - type: 'String', - value: '"B"', - - range: [139, 142], - loc: { - start: { column: 16, line: 4 }, - end: { column: 19, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ',', - - range: [142, 143], - loc: { - start: { column: 19, line: 4 }, - end: { column: 20, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '{', - - range: [144, 145], - loc: { - start: { column: 21, line: 4 }, - end: { column: 22, line: 4 }, - }, - }, - Identifier { - type: 'Identifier', - value: 'assert', - - range: [146, 152], - loc: { - start: { column: 23, line: 4 }, - end: { column: 29, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ':', - - range: [152, 153], - loc: { - start: { column: 29, line: 4 }, - end: { column: 30, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '{', - - range: [154, 155], - loc: { - start: { column: 31, line: 4 }, - end: { column: 32, line: 4 }, - }, - }, - Identifier { - type: 'Identifier', - value: 'type', - - range: [156, 160], - loc: { - start: { column: 33, line: 4 }, - end: { column: 37, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ':', - - range: [160, 161], - loc: { - start: { column: 37, line: 4 }, - end: { column: 38, line: 4 }, - }, - }, - String { - type: 'String', - value: '"json"', - - range: [162, 168], - loc: { - start: { column: 39, line: 4 }, - end: { column: 45, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '}', - - range: [169, 170], - loc: { - start: { column: 46, line: 4 }, - end: { column: 47, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '}', - - range: [171, 172], - loc: { - start: { column: 48, line: 4 }, - end: { column: 49, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ')', - - range: [172, 173], - loc: { - start: { column: 49, line: 4 }, - end: { column: 50, line: 4 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ';', - - range: [173, 174], - loc: { - start: { column: 50, line: 4 }, - end: { column: 51, line: 4 }, - }, - }, - ] diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot index 77762c062843..ed2aaeeb9abe 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-ast.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot @@ -524,5 +524,6 @@ exports[`AST Fixtures > List fixtures with AST differences`] "statement/ForInStatement/fixtures/expr-init/fixture.ts", "statement/ForOfStatement/fixtures/expr-init/fixture.ts", "statement/ForOfStatement/fixtures/using-declaration/fixture.ts", - "type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts" + "type/TSImportType/fixtures/type-import-type-with-import-attributes-assert/fixture.ts", + "type/TSImportType/fixtures/type-import-type-with-import-attributes-with/fixture.ts" ] diff --git a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot index 3a3acb3c5aef..fc6544193cf1 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot @@ -134,5 +134,5 @@ exports[`AST Fixtures > List fixtures with Token differences`] "special/TSTypeParameter/fixtures/interface-const-modifier-multiple/fixture.ts", "special/TSTypeParameter/fixtures/interface-const-modifier/fixture.ts", "special/TSTypeParameter/fixtures/interface-in-const-modifier-multiple/fixture.ts", - "type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts" + "type/TSImportType/fixtures/type-import-type-with-import-attributes-with/fixture.ts" ] From 7af8e537c88e4166ca5b7bb6b8bc161fe1ed52db Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Fri, 2 May 2025 22:37:26 +0100 Subject: [PATCH 3/3] Use token kind --- packages/typescript-estree/src/convert.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 8c2055a591be..50740027907e 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -3124,7 +3124,10 @@ export class Converter { this.ast, )!; const withOrAssertTokenRange = getRange(withOrAssertToken, this.ast); - const withOrAssertName = withOrAssertToken.getText(); + const withOrAssertName = + withOrAssertToken.kind === ts.SyntaxKind.AssertKeyword + ? 'assert' + : 'with'; options = this.createNode(node, { type: AST_NODE_TYPES.ObjectExpression,