From 33db5e9ac19a7c6dca5edd66f1210c3e1c3f0478 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Tue, 29 Apr 2025 11:35:16 +0100 Subject: [PATCH] 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, }),