From f13387404d7291c2a2f3191cec9e13b111d673b2 Mon Sep 17 00:00:00 2001 From: dbarabashh Date: Thu, 17 Apr 2025 17:11:57 +0200 Subject: [PATCH 01/12] ensure consistent TSMappedType ast shape --- packages/typescript-estree/src/convert.ts | 16 ++--- .../tests/lib/convert.test.ts | 58 +++++++++++++++++++ 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 7faa5353b12c..83aa176ef074 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2870,14 +2870,14 @@ export class Converter { constraint: this.convertChild(node.typeParameter.constraint), key: this.convertChild(node.typeParameter.name), nameType: this.convertChild(node.nameType) ?? null, - optional: - node.questionToken && - (node.questionToken.kind === SyntaxKind.QuestionToken || - getTextForTokenKind(node.questionToken.kind)), - readonly: - node.readonlyToken && - (node.readonlyToken.kind === SyntaxKind.ReadonlyKeyword || - getTextForTokenKind(node.readonlyToken.kind)), + optional: node.questionToken + ? node.questionToken.kind === SyntaxKind.QuestionToken || + getTextForTokenKind(node.questionToken.kind) + : false, + readonly: node.readonlyToken + ? node.readonlyToken.kind === SyntaxKind.ReadonlyKeyword || + getTextForTokenKind(node.readonlyToken.kind) + : undefined, typeAnnotation: node.type && this.convertChild(node.type), }, 'typeParameter', diff --git a/packages/typescript-estree/tests/lib/convert.test.ts b/packages/typescript-estree/tests/lib/convert.test.ts index 1473680fb8ec..14e8793218a8 100644 --- a/packages/typescript-estree/tests/lib/convert.test.ts +++ b/packages/typescript-estree/tests/lib/convert.test.ts @@ -449,5 +449,63 @@ describe('convert', () => { expect(tsMappedType.typeParameter).toBeUndefined(); expect(Object.keys(tsMappedType)).toContain('typeParameter'); }); + + describe('TSMappedType AST shape consistency', () => { + const getMappedTypeFromCode = (code: string): TSESTree.TSMappedType => { + const ast = convertCode(code); + const instance = new Converter(ast); + const program = instance.convertProgram(); + const varDec = program.body[0] as TSESTree.VariableDeclaration; + const typeAnnotation = varDec.declarations[0]?.id?.typeAnnotation; + if (!typeAnnotation) { + throw new Error('Type annotation is undefined'); + } + return typeAnnotation.typeAnnotation as TSESTree.TSMappedType; + }; + + it('should have optional=false when no optional modifier is present', () => { + const mappedType = getMappedTypeFromCode('var a: { [k in any]: any };'); + + expect(mappedType).toHaveProperty('optional', false); + }); + + it('should have optional=true when optional modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var b: { [k in any]?: any };', + ); + + expect(mappedType).toHaveProperty('optional', true); + }); + + it('should have readonly=undefined when no readonly modifier is present', () => { + const mappedType = getMappedTypeFromCode('var a: { [k in any]: any };'); + + expect(mappedType).toHaveProperty('readonly', undefined); + }); + + it('should have readonly=true when readonly modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var c: { readonly [k in any]: any };', + ); + + expect(mappedType).toHaveProperty('readonly', true); + }); + + it('should have readonly="+" when +readonly modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var d: { +readonly [k in any]: any };', + ); + + expect(mappedType).toHaveProperty('readonly', '+'); + }); + + it('should have readonly="-" when -readonly modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var e: { -readonly [k in any]: any };', + ); + + expect(mappedType).toHaveProperty('readonly', '-'); + }); + }); }); }); From b6e71eb3450793ebf176cdc499d914247cf4fbd0 Mon Sep 17 00:00:00 2001 From: dbarabashh Date: Thu, 17 Apr 2025 17:46:58 +0200 Subject: [PATCH 02/12] added mote tests --- .../typescript-estree/tests/lib/convert.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/typescript-estree/tests/lib/convert.test.ts b/packages/typescript-estree/tests/lib/convert.test.ts index 14e8793218a8..dabf814b6b31 100644 --- a/packages/typescript-estree/tests/lib/convert.test.ts +++ b/packages/typescript-estree/tests/lib/convert.test.ts @@ -506,6 +506,22 @@ describe('convert', () => { expect(mappedType).toHaveProperty('readonly', '-'); }); + + it('should have optional="+" when +? modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var f: { [k in any]+?: any };', + ); + + expect(mappedType).toHaveProperty('optional', '+'); + }); + + it('should have optional="-" when -? modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var g: { [k in any]-?: any };', + ); + + expect(mappedType).toHaveProperty('optional', '-'); + }); }); }); }); From 8027033cb501cc5e195b412d5af7ed15ad3e833e Mon Sep 17 00:00:00 2001 From: dbarabashh Date: Sat, 3 May 2025 16:03:37 +0200 Subject: [PATCH 03/12] updated tests --- .../snapshots/1-TSESTree-AST.shot | 1 + .../snapshots/5-AST-Alignment-AST.shot | 9 ++- .../snapshots/1-TSESTree-AST.shot | 1 + .../snapshots/5-AST-Alignment-AST.shot | 1 + .../mapped/snapshots/1-TSESTree-AST.shot | 1 + .../mapped/snapshots/5-AST-Alignment-AST.shot | 55 ++++++------- .../fixtures/valid/base/fixture.ts | 1 + .../fixtures/valid/no-modifiers/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 31 ++++++++ .../fixtures/valid/with-modifiers/fixture.ts | 5 ++ .../snapshots/1-TSESTree-AST.shot | 78 +++++++++++++++++++ .../tests/lib/convert.test.ts | 74 ------------------ 12 files changed, 155 insertions(+), 105 deletions(-) create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/valid/base/fixture.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/fixture.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/fixture.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/snapshots/1-TSESTree-AST.shot diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-named-type/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-named-type/snapshots/1-TSESTree-AST.shot index bd1c860246c7..1b6a8258fa1b 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-named-type/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-named-type/snapshots/1-TSESTree-AST.shot @@ -81,6 +81,7 @@ Program { end: { column: 22, line: 4 }, }, }, + optional: false, typeAnnotation: TSIndexedAccessType { type: "TSIndexedAccessType", indexType: TSTypeReference { diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-named-type/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-named-type/snapshots/5-AST-Alignment-AST.shot index c35480a4e34a..9880c4e448e3 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-named-type/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-named-type/snapshots/5-AST-Alignment-AST.shot @@ -88,6 +88,7 @@ Snapshot Diff: end: { column: 22, line: 4 }, }, }, +- optional: false, typeAnnotation: TSIndexedAccessType { type: 'TSIndexedAccessType', indexType: TSTypeReference { @@ -137,8 +138,8 @@ Snapshot Diff: loc: { start: { column: 25, line: 4 }, end: { column: 29, line: 4 }, - }, - }, ++ }, ++ }, + typeParameter: TSTypeParameter { + type: 'TSTypeParameter', + constraint: TSTypeOperator { @@ -176,8 +177,8 @@ Snapshot Diff: + loc: { + start: { column: 3, line: 4 }, + end: { column: 15, line: 4 }, -+ }, -+ }, + }, + }, range: [88, 122], loc: { diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-untypped/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-untypped/snapshots/1-TSESTree-AST.shot index f4b40bb33c3e..4000cf45965c 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-untypped/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-untypped/snapshots/1-TSESTree-AST.shot @@ -38,6 +38,7 @@ Program { }, }, nameType: null, + optional: false, range: [82, 99], loc: { diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-untypped/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-untypped/snapshots/5-AST-Alignment-AST.shot index d3eae2e1b02f..69cf164569b8 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-untypped/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-untypped/snapshots/5-AST-Alignment-AST.shot @@ -57,6 +57,7 @@ Snapshot Diff: }, }, - nameType: null, +- optional: false, range: [82, 99], loc: { diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped/snapshots/1-TSESTree-AST.shot index d32a917d685f..6b1b9f2820d2 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped/snapshots/1-TSESTree-AST.shot @@ -38,6 +38,7 @@ Program { }, }, nameType: null, + optional: false, typeAnnotation: TSNumberKeyword { type: "TSNumberKeyword", diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped/snapshots/5-AST-Alignment-AST.shot index c90c3cfd4ba4..fd7eca35a7f5 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped/snapshots/5-AST-Alignment-AST.shot @@ -25,22 +25,36 @@ Snapshot Diff: type: 'TSMappedType', - constraint: TSStringKeyword { - type: 'TSStringKeyword', -+ nameType: null, -+ typeAnnotation: TSNumberKeyword { -+ type: 'TSNumberKeyword', - +- - range: [90, 96], -+ range: [99, 105], - loc: { +- loc: { - start: { column: 17, line: 3 }, - end: { column: 23, line: 3 }, -+ start: { column: 26, line: 3 }, -+ end: { column: 32, line: 3 }, - }, - }, +- }, +- }, - key: Identifier { - type: 'Identifier', - decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [85, 86], +- loc: { +- start: { column: 12, line: 3 }, +- end: { column: 13, line: 3 }, +- }, +- }, + nameType: null, +- optional: false, + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [99, 105], + loc: { + start: { column: 26, line: 3 }, + end: { column: 32, line: 3 }, ++ }, ++ }, + typeParameter: TSTypeParameter { + type: 'TSTypeParameter', + constraint: TSStringKeyword { @@ -52,24 +66,11 @@ Snapshot Diff: + end: { column: 23, line: 3 }, + }, + }, - name: 'P', -- optional: false, - -- range: [85, 86], ++ name: 'P', ++ + range: [85, 96], - loc: { - start: { column: 12, line: 3 }, -- end: { column: 13, line: 3 }, -- }, -- }, -- nameType: null, -- typeAnnotation: TSNumberKeyword { -- type: 'TSNumberKeyword', -- -- range: [99, 105], -- loc: { -- start: { column: 26, line: 3 }, -- end: { column: 32, line: 3 }, ++ loc: { ++ start: { column: 12, line: 3 }, + end: { column: 23, line: 3 }, }, }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/base/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/base/fixture.ts new file mode 100644 index 000000000000..0482553071a0 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/base/fixture.ts @@ -0,0 +1 @@ +let map: { [P in string]: number }; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/fixture.ts new file mode 100644 index 000000000000..f40ba5446116 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/fixture.ts @@ -0,0 +1,3 @@ +type T = { + [K in any]: any; +}; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..6b706706c7b6 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,31 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures type TSMappedType valid no-modifiers TSESTree - AST 1`] = ` +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + optional: false, + readonly: undefined, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + name: "K", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + }, + }, + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + }, + }, + }, + ], + sourceType: "script", +} diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/fixture.ts new file mode 100644 index 000000000000..31a90800a2a8 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/fixture.ts @@ -0,0 +1,5 @@ +type T = { + readonly [P in string]?: number; + +readonly [P in string]: number; + -readonly [P in string]-?: number; +}; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..ee78cf0fa24d --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,78 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures type TSMappedType valid with-modifiers TSESTree - AST 1`] = ` +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + }, + typeAnnotation: TSTypeLiteral { + type: "TSTypeLiteral", + members: [ + TSPropertySignature { + type: "TSPropertySignature", + computed: true, + key: TSMappedType { + type: "TSMappedType", + optional: true, + readonly: true, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + name: "K", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + }, + }, + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + }, + }, + }, + TSPropertySignature { + type: "TSPropertySignature", + computed: true, + key: TSMappedType { + type: "TSMappedType", + optional: false, + readonly: "+", + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + name: "K", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + }, + }, + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + }, + }, + }, + TSPropertySignature { + type: "TSPropertySignature", + computed: true, + key: TSMappedType { + type: "TSMappedType", + optional: "-", + readonly: "-", + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + name: "K", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + }, + }, + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + }, + }, + }, + ], + }, + }, + ], + sourceType: "script", +} diff --git a/packages/typescript-estree/tests/lib/convert.test.ts b/packages/typescript-estree/tests/lib/convert.test.ts index dabf814b6b31..1473680fb8ec 100644 --- a/packages/typescript-estree/tests/lib/convert.test.ts +++ b/packages/typescript-estree/tests/lib/convert.test.ts @@ -449,79 +449,5 @@ describe('convert', () => { expect(tsMappedType.typeParameter).toBeUndefined(); expect(Object.keys(tsMappedType)).toContain('typeParameter'); }); - - describe('TSMappedType AST shape consistency', () => { - const getMappedTypeFromCode = (code: string): TSESTree.TSMappedType => { - const ast = convertCode(code); - const instance = new Converter(ast); - const program = instance.convertProgram(); - const varDec = program.body[0] as TSESTree.VariableDeclaration; - const typeAnnotation = varDec.declarations[0]?.id?.typeAnnotation; - if (!typeAnnotation) { - throw new Error('Type annotation is undefined'); - } - return typeAnnotation.typeAnnotation as TSESTree.TSMappedType; - }; - - it('should have optional=false when no optional modifier is present', () => { - const mappedType = getMappedTypeFromCode('var a: { [k in any]: any };'); - - expect(mappedType).toHaveProperty('optional', false); - }); - - it('should have optional=true when optional modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var b: { [k in any]?: any };', - ); - - expect(mappedType).toHaveProperty('optional', true); - }); - - it('should have readonly=undefined when no readonly modifier is present', () => { - const mappedType = getMappedTypeFromCode('var a: { [k in any]: any };'); - - expect(mappedType).toHaveProperty('readonly', undefined); - }); - - it('should have readonly=true when readonly modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var c: { readonly [k in any]: any };', - ); - - expect(mappedType).toHaveProperty('readonly', true); - }); - - it('should have readonly="+" when +readonly modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var d: { +readonly [k in any]: any };', - ); - - expect(mappedType).toHaveProperty('readonly', '+'); - }); - - it('should have readonly="-" when -readonly modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var e: { -readonly [k in any]: any };', - ); - - expect(mappedType).toHaveProperty('readonly', '-'); - }); - - it('should have optional="+" when +? modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var f: { [k in any]+?: any };', - ); - - expect(mappedType).toHaveProperty('optional', '+'); - }); - - it('should have optional="-" when -? modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var g: { [k in any]-?: any };', - ); - - expect(mappedType).toHaveProperty('optional', '-'); - }); - }); }); }); From 6c3cb8734949b0c2bff69a5e476d4cd688f5c5b5 Mon Sep 17 00:00:00 2001 From: dbarabashh Date: Sat, 3 May 2025 16:09:35 +0200 Subject: [PATCH 04/12] fix --- .../TSMappedType/fixtures/valid/with-modifiers/fixture.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/fixture.ts index 31a90800a2a8..b2f2e7c41654 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/fixture.ts +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/fixture.ts @@ -1,5 +1,11 @@ -type T = { +type ReadonlyOptional = { readonly [P in string]?: number; +}; + +type PlusReadonly = { +readonly [P in string]: number; +}; + +type MinusReadonlyOptional = { -readonly [P in string]-?: number; }; From 9d64c324619cda9e63b48c93fbe693bb67b2db54 Mon Sep 17 00:00:00 2001 From: dbarabashh Date: Sat, 3 May 2025 20:23:01 +0200 Subject: [PATCH 05/12] updated --- .../tests/lib/convert.test.ts | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/packages/typescript-estree/tests/lib/convert.test.ts b/packages/typescript-estree/tests/lib/convert.test.ts index 1473680fb8ec..dabf814b6b31 100644 --- a/packages/typescript-estree/tests/lib/convert.test.ts +++ b/packages/typescript-estree/tests/lib/convert.test.ts @@ -449,5 +449,79 @@ describe('convert', () => { expect(tsMappedType.typeParameter).toBeUndefined(); expect(Object.keys(tsMappedType)).toContain('typeParameter'); }); + + describe('TSMappedType AST shape consistency', () => { + const getMappedTypeFromCode = (code: string): TSESTree.TSMappedType => { + const ast = convertCode(code); + const instance = new Converter(ast); + const program = instance.convertProgram(); + const varDec = program.body[0] as TSESTree.VariableDeclaration; + const typeAnnotation = varDec.declarations[0]?.id?.typeAnnotation; + if (!typeAnnotation) { + throw new Error('Type annotation is undefined'); + } + return typeAnnotation.typeAnnotation as TSESTree.TSMappedType; + }; + + it('should have optional=false when no optional modifier is present', () => { + const mappedType = getMappedTypeFromCode('var a: { [k in any]: any };'); + + expect(mappedType).toHaveProperty('optional', false); + }); + + it('should have optional=true when optional modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var b: { [k in any]?: any };', + ); + + expect(mappedType).toHaveProperty('optional', true); + }); + + it('should have readonly=undefined when no readonly modifier is present', () => { + const mappedType = getMappedTypeFromCode('var a: { [k in any]: any };'); + + expect(mappedType).toHaveProperty('readonly', undefined); + }); + + it('should have readonly=true when readonly modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var c: { readonly [k in any]: any };', + ); + + expect(mappedType).toHaveProperty('readonly', true); + }); + + it('should have readonly="+" when +readonly modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var d: { +readonly [k in any]: any };', + ); + + expect(mappedType).toHaveProperty('readonly', '+'); + }); + + it('should have readonly="-" when -readonly modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var e: { -readonly [k in any]: any };', + ); + + expect(mappedType).toHaveProperty('readonly', '-'); + }); + + it('should have optional="+" when +? modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var f: { [k in any]+?: any };', + ); + + expect(mappedType).toHaveProperty('optional', '+'); + }); + + it('should have optional="-" when -? modifier is present', () => { + const mappedType = getMappedTypeFromCode( + 'var g: { [k in any]-?: any };', + ); + + expect(mappedType).toHaveProperty('optional', '-'); + }); + }); }); }); From 33112feffb37e4a4fe15e6062d6295da68109816 Mon Sep 17 00:00:00 2001 From: bradzacher Date: Mon, 5 May 2025 12:03:12 +0930 Subject: [PATCH 06/12] fix fixture folders --- .../fixtures/{valid => }/base/fixture.ts | 0 .../base/snapshots/1-TSESTree-AST.shot | 98 ++++ .../base/snapshots/2-TSESTree-Tokens.shot | 132 +++++ .../fixtures/base/snapshots/3-Babel-AST.shot | 91 ++++ .../base/snapshots/4-Babel-Tokens.shot | 132 +++++ .../base/snapshots/5-AST-Alignment-AST.shot | 124 +++++ .../snapshots/6-AST-Alignment-Tokens.shot | 141 +++++ .../{valid => }/no-modifiers/fixture.ts | 0 .../snapshots/1-TSESTree-AST.shot | 75 +++ .../snapshots/2-TSESTree-Tokens.shot | 142 +++++ .../no-modifiers/snapshots/3-Babel-AST.shot | 69 +++ .../snapshots/4-Babel-Tokens.shot | 142 +++++ .../snapshots/5-AST-Alignment-AST.shot | 100 ++++ .../snapshots/6-AST-Alignment-Tokens.shot | 5 + .../snapshots/1-TSESTree-AST.shot | 31 -- .../snapshots/1-TSESTree-AST.shot | 78 --- .../{valid => }/with-modifiers/fixture.ts | 0 .../snapshots/1-TSESTree-AST.shot | 204 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 502 ++++++++++++++++++ .../with-modifiers/snapshots/3-Babel-AST.shot | 188 +++++++ .../snapshots/4-Babel-Tokens.shot | 502 ++++++++++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 268 ++++++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 5 + .../tests/fixtures-with-differences-ast.shot | 5 +- .../fixtures-with-differences-tokens.shot | 3 +- 25 files changed, 2926 insertions(+), 111 deletions(-) rename packages/ast-spec/src/type/TSMappedType/fixtures/{valid => }/base/fixture.ts (100%) create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/6-AST-Alignment-Tokens.shot rename packages/ast-spec/src/type/TSMappedType/fixtures/{valid => }/no-modifiers/fixture.ts (100%) create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/6-AST-Alignment-Tokens.shot delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/snapshots/1-TSESTree-AST.shot delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/snapshots/1-TSESTree-AST.shot rename packages/ast-spec/src/type/TSMappedType/fixtures/{valid => }/with-modifiers/fixture.ts (100%) create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/6-AST-Alignment-Tokens.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/base/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/base/fixture.ts similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/valid/base/fixture.ts rename to packages/ast-spec/src/type/TSMappedType/fixtures/base/fixture.ts diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..a44ff979d52c --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,98 @@ +Program { + type: "Program", + body: [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: [ + VariableDeclarator { + type: "VariableDeclarator", + definite: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "map", + optional: false, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [17, 23], + loc: { + start: { column: 17, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + nameType: null, + optional: false, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [9, 34], + loc: { + start: { column: 9, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + + range: [7, 34], + loc: { + start: { column: 7, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + + range: [4, 34], + loc: { + start: { column: 4, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + init: null, + + range: [4, 34], + loc: { + start: { column: 4, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + ], + declare: false, + kind: "let", + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 36], + 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/TSMappedType/fixtures/base/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..85461341dfcc --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,132 @@ +[ + Keyword { + type: "Keyword", + value: "let", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "map", + + range: [4, 7], + loc: { + start: { column: 4, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [14, 16], + loc: { + start: { column: 14, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [17, 23], + loc: { + start: { column: 17, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [33, 34], + loc: { + start: { column: 33, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [34, 35], + loc: { + start: { column: 34, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..99fdaf143184 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/3-Babel-AST.shot @@ -0,0 +1,91 @@ +Program { + type: "Program", + body: [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "map", + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [17, 23], + loc: { + start: { column: 17, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + name: "P", + + range: [12, 23], + loc: { + start: { column: 12, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + + range: [9, 34], + loc: { + start: { column: 9, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + + range: [7, 34], + loc: { + start: { column: 7, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + + range: [4, 34], + loc: { + start: { column: 4, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + init: null, + + range: [4, 34], + loc: { + start: { column: 4, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + ], + kind: "let", + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 36], + 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/TSMappedType/fixtures/base/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..1ee42402051d --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,132 @@ +[ + Identifier { + type: "Identifier", + value: "let", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "map", + + range: [4, 7], + loc: { + start: { column: 4, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [14, 16], + loc: { + start: { column: 14, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [17, 23], + loc: { + start: { column: 17, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [33, 34], + loc: { + start: { column: 33, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [34, 35], + loc: { + start: { column: 34, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..c73767153f9d --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,124 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > base > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + VariableDeclaration { + type: 'VariableDeclaration', + declarations: Array [ + VariableDeclarator { + type: 'VariableDeclarator', +- definite: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'map', +- optional: false, + typeAnnotation: TSTypeAnnotation { + type: 'TSTypeAnnotation', + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [17, 23], +- loc: { +- start: { column: 17, line: 1 }, +- end: { column: 23, line: 1 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [12, 13], +- loc: { +- start: { column: 12, line: 1 }, +- end: { column: 13, line: 1 }, +- }, +- }, + nameType: null, +- optional: false, + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, ++ }, ++ }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', ++ ++ range: [17, 23], ++ loc: { ++ start: { column: 17, line: 1 }, ++ end: { column: 23, line: 1 }, ++ }, ++ }, ++ name: 'P', ++ ++ range: [12, 23], ++ loc: { ++ start: { column: 12, line: 1 }, ++ end: { column: 23, line: 1 }, + }, + }, + + range: [9, 34], + loc: { + start: { column: 9, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + + range: [7, 34], + loc: { + start: { column: 7, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + + range: [4, 34], + loc: { + start: { column: 4, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + init: null, + + range: [4, 34], + loc: { + start: { column: 4, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + ], +- declare: false, + kind: 'let', + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 36], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..7b780c658454 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,141 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > base > AST Alignment - Token`] +Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'let', + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'map', + + range: [4, 7], + loc: { + start: { column: 4, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ':', + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '[', + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'P', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'in', + + range: [14, 16], + loc: { + start: { column: 14, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'string', + + range: [17, 23], + loc: { + start: { column: 17, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ']', + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ':', + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'number', + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [33, 34], + loc: { + start: { column: 33, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [34, 35], + loc: { + start: { column: 34, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + ] diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/fixture.ts similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/fixture.ts rename to packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/fixture.ts diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..d696e642a0fd --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,75 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "T", + optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "K", + optional: false, + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + nameType: null, + optional: false, + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [25, 28], + loc: { + start: { column: 14, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + + range: [9, 31], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..96a010ab783d --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,142 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "K", + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [16, 18], + loc: { + start: { column: 5, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [22, 23], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [23, 24], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [25, 28], + loc: { + start: { column: 14, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [28, 29], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [30, 31], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [31, 32], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..493867ad4561 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/3-Babel-AST.shot @@ -0,0 +1,69 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [25, 28], + loc: { + start: { column: 14, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + name: "K", + + range: [14, 22], + loc: { + start: { column: 3, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + + range: [9, 31], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..96a010ab783d --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,142 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "K", + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [16, 18], + loc: { + start: { column: 5, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [22, 23], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [23, 24], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [25, 28], + loc: { + start: { column: 14, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [28, 29], + loc: { + start: { column: 17, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [30, 31], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [31, 32], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..7690d33999d5 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,100 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > no-modifiers > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'T', +- optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSAnyKeyword { ++ nameType: null, ++ typeAnnotation: TSAnyKeyword { + type: 'TSAnyKeyword', + +- range: [19, 22], ++ range: [25, 28], + loc: { +- start: { column: 8, line: 2 }, +- end: { column: 11, line: 2 }, ++ start: { column: 14, line: 2 }, ++ end: { column: 17, line: 2 }, + }, + }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSAnyKeyword { ++ type: 'TSAnyKeyword', ++ ++ range: [19, 22], ++ loc: { ++ start: { column: 8, line: 2 }, ++ end: { column: 11, line: 2 }, ++ }, ++ }, + name: 'K', +- optional: false, + +- range: [14, 15], ++ range: [14, 22], + loc: { + start: { column: 3, line: 2 }, +- end: { column: 4, line: 2 }, +- }, +- }, +- nameType: null, +- optional: false, +- typeAnnotation: TSAnyKeyword { +- type: 'TSAnyKeyword', +- +- range: [25, 28], +- loc: { +- start: { column: 14, line: 2 }, +- end: { column: 17, line: 2 }, ++ end: { column: 11, line: 2 }, + }, + }, + + range: [9, 31], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..abfcfdb9ba8d --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/no-modifiers/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,5 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > no-modifiers > AST Alignment - Token`] +Snapshot Diff: +Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/snapshots/1-TSESTree-AST.shot deleted file mode 100644 index 6b706706c7b6..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/no-modifiers/snapshots/1-TSESTree-AST.shot +++ /dev/null @@ -1,31 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures type TSMappedType valid no-modifiers TSESTree - AST 1`] = ` -Program { - type: "Program", - body: [ - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - id: Identifier { - type: "Identifier", - name: "T", - }, - typeAnnotation: TSMappedType { - type: "TSMappedType", - optional: false, - readonly: undefined, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - name: "K", - constraint: TSAnyKeyword { - type: "TSAnyKeyword", - }, - }, - typeAnnotation: TSAnyKeyword { - type: "TSAnyKeyword", - }, - }, - }, - ], - sourceType: "script", -} diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/snapshots/1-TSESTree-AST.shot deleted file mode 100644 index ee78cf0fa24d..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/snapshots/1-TSESTree-AST.shot +++ /dev/null @@ -1,78 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures type TSMappedType valid with-modifiers TSESTree - AST 1`] = ` -Program { - type: "Program", - body: [ - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - id: Identifier { - type: "Identifier", - name: "T", - }, - typeAnnotation: TSTypeLiteral { - type: "TSTypeLiteral", - members: [ - TSPropertySignature { - type: "TSPropertySignature", - computed: true, - key: TSMappedType { - type: "TSMappedType", - optional: true, - readonly: true, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - name: "K", - constraint: TSAnyKeyword { - type: "TSAnyKeyword", - }, - }, - typeAnnotation: TSAnyKeyword { - type: "TSAnyKeyword", - }, - }, - }, - TSPropertySignature { - type: "TSPropertySignature", - computed: true, - key: TSMappedType { - type: "TSMappedType", - optional: false, - readonly: "+", - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - name: "K", - constraint: TSAnyKeyword { - type: "TSAnyKeyword", - }, - }, - typeAnnotation: TSAnyKeyword { - type: "TSAnyKeyword", - }, - }, - }, - TSPropertySignature { - type: "TSPropertySignature", - computed: true, - key: TSMappedType { - type: "TSMappedType", - optional: "-", - readonly: "-", - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - name: "K", - constraint: TSAnyKeyword { - type: "TSAnyKeyword", - }, - }, - typeAnnotation: TSAnyKeyword { - type: "TSAnyKeyword", - }, - }, - }, - ], - }, - }, - ], - sourceType: "script", -} diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/fixture.ts similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/valid/with-modifiers/fixture.ts rename to packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/fixture.ts diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..ac5c50a2629c --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,204 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "ReadonlyOptional", + optional: false, + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + nameType: null, + optional: true, + readonly: true, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + + range: [24, 62], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 63], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "PlusReadonly", + optional: false, + + range: [70, 82], + loc: { + start: { column: 5, line: 5 }, + end: { column: 17, line: 5 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [105, 111], + loc: { + start: { column: 18, line: 6 }, + end: { column: 24, line: 6 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [100, 101], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + nameType: null, + optional: false, + readonly: "+", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [114, 120], + loc: { + start: { column: 27, line: 6 }, + end: { column: 33, line: 6 }, + }, + }, + + range: [85, 123], + loc: { + start: { column: 20, line: 5 }, + end: { column: 1, line: 7 }, + }, + }, + + range: [65, 124], + loc: { + start: { column: 0, line: 5 }, + end: { column: 2, line: 7 }, + }, + }, + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "MinusReadonlyOptional", + optional: false, + + range: [131, 152], + loc: { + start: { column: 5, line: 9 }, + end: { column: 26, line: 9 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [175, 181], + loc: { + start: { column: 18, line: 10 }, + end: { column: 24, line: 10 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [170, 171], + loc: { + start: { column: 13, line: 10 }, + end: { column: 14, line: 10 }, + }, + }, + nameType: null, + optional: "-", + readonly: "-", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [186, 192], + loc: { + start: { column: 29, line: 10 }, + end: { column: 35, line: 10 }, + }, + }, + + range: [155, 195], + loc: { + start: { column: 29, line: 9 }, + end: { column: 1, line: 11 }, + }, + }, + + range: [126, 196], + loc: { + start: { column: 0, line: 9 }, + end: { column: 2, line: 11 }, + }, + }, + ], + sourceType: "script", + + range: [0, 197], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 12 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..d76c84b19633 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,502 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [28, 36], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [37, 38], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [40, 42], + loc: { + start: { column: 14, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [49, 50], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [50, 51], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [51, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [59, 60], + loc: { + start: { column: 33, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [61, 62], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [62, 63], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [65, 69], + loc: { + start: { column: 0, line: 5 }, + end: { column: 4, line: 5 }, + }, + }, + Identifier { + type: "Identifier", + value: "PlusReadonly", + + range: [70, 82], + loc: { + start: { column: 5, line: 5 }, + end: { column: 17, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [83, 84], + loc: { + start: { column: 18, line: 5 }, + end: { column: 19, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [85, 86], + loc: { + start: { column: 20, line: 5 }, + end: { column: 21, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "+", + + range: [89, 90], + loc: { + start: { column: 2, line: 6 }, + end: { column: 3, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [90, 98], + loc: { + start: { column: 3, line: 6 }, + end: { column: 11, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [99, 100], + loc: { + start: { column: 12, line: 6 }, + end: { column: 13, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [100, 101], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [102, 104], + loc: { + start: { column: 15, line: 6 }, + end: { column: 17, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [105, 111], + loc: { + start: { column: 18, line: 6 }, + end: { column: 24, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [111, 112], + loc: { + start: { column: 24, line: 6 }, + end: { column: 25, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [112, 113], + loc: { + start: { column: 25, line: 6 }, + end: { column: 26, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [114, 120], + loc: { + start: { column: 27, line: 6 }, + end: { column: 33, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [120, 121], + loc: { + start: { column: 33, line: 6 }, + end: { column: 34, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [122, 123], + loc: { + start: { column: 0, line: 7 }, + end: { column: 1, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [123, 124], + loc: { + start: { column: 1, line: 7 }, + end: { column: 2, line: 7 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [126, 130], + loc: { + start: { column: 0, line: 9 }, + end: { column: 4, line: 9 }, + }, + }, + Identifier { + type: "Identifier", + value: "MinusReadonlyOptional", + + range: [131, 152], + loc: { + start: { column: 5, line: 9 }, + end: { column: 26, line: 9 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [153, 154], + loc: { + start: { column: 27, line: 9 }, + end: { column: 28, line: 9 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [155, 156], + loc: { + start: { column: 29, line: 9 }, + end: { column: 30, line: 9 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "-", + + range: [159, 160], + loc: { + start: { column: 2, line: 10 }, + end: { column: 3, line: 10 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [160, 168], + loc: { + start: { column: 3, line: 10 }, + end: { column: 11, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [169, 170], + loc: { + start: { column: 12, line: 10 }, + end: { column: 13, line: 10 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [170, 171], + loc: { + start: { column: 13, line: 10 }, + end: { column: 14, line: 10 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [172, 174], + loc: { + start: { column: 15, line: 10 }, + end: { column: 17, line: 10 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [175, 181], + loc: { + start: { column: 18, line: 10 }, + end: { column: 24, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [181, 182], + loc: { + start: { column: 24, line: 10 }, + end: { column: 25, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "-", + + range: [182, 183], + loc: { + start: { column: 25, line: 10 }, + end: { column: 26, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [183, 184], + loc: { + start: { column: 26, line: 10 }, + end: { column: 27, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [184, 185], + loc: { + start: { column: 27, line: 10 }, + end: { column: 28, line: 10 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [186, 192], + loc: { + start: { column: 29, line: 10 }, + end: { column: 35, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [192, 193], + loc: { + start: { column: 35, line: 10 }, + end: { column: 36, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [194, 195], + loc: { + start: { column: 0, line: 11 }, + end: { column: 1, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [195, 196], + loc: { + start: { column: 1, line: 11 }, + end: { column: 2, line: 11 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..cc364f2de4ec --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/3-Babel-AST.shot @@ -0,0 +1,188 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + optional: true, + readonly: true, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + name: "P", + + range: [38, 49], + loc: { + start: { column: 12, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + + range: [24, 62], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 63], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "PlusReadonly", + + range: [70, 82], + loc: { + start: { column: 5, line: 5 }, + end: { column: 17, line: 5 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + readonly: "+", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [114, 120], + loc: { + start: { column: 27, line: 6 }, + end: { column: 33, line: 6 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [105, 111], + loc: { + start: { column: 18, line: 6 }, + end: { column: 24, line: 6 }, + }, + }, + name: "P", + + range: [100, 111], + loc: { + start: { column: 13, line: 6 }, + end: { column: 24, line: 6 }, + }, + }, + + range: [85, 123], + loc: { + start: { column: 20, line: 5 }, + end: { column: 1, line: 7 }, + }, + }, + + range: [65, 124], + loc: { + start: { column: 0, line: 5 }, + end: { column: 2, line: 7 }, + }, + }, + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "MinusReadonlyOptional", + + range: [131, 152], + loc: { + start: { column: 5, line: 9 }, + end: { column: 26, line: 9 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + optional: "-", + readonly: "-", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [186, 192], + loc: { + start: { column: 29, line: 10 }, + end: { column: 35, line: 10 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [175, 181], + loc: { + start: { column: 18, line: 10 }, + end: { column: 24, line: 10 }, + }, + }, + name: "P", + + range: [170, 181], + loc: { + start: { column: 13, line: 10 }, + end: { column: 24, line: 10 }, + }, + }, + + range: [155, 195], + loc: { + start: { column: 29, line: 9 }, + end: { column: 1, line: 11 }, + }, + }, + + range: [126, 196], + loc: { + start: { column: 0, line: 9 }, + end: { column: 2, line: 11 }, + }, + }, + ], + sourceType: "script", + + range: [0, 197], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 12 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..d76c84b19633 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,502 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [28, 36], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [37, 38], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [40, 42], + loc: { + start: { column: 14, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [49, 50], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [50, 51], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [51, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [59, 60], + loc: { + start: { column: 33, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [61, 62], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [62, 63], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [65, 69], + loc: { + start: { column: 0, line: 5 }, + end: { column: 4, line: 5 }, + }, + }, + Identifier { + type: "Identifier", + value: "PlusReadonly", + + range: [70, 82], + loc: { + start: { column: 5, line: 5 }, + end: { column: 17, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [83, 84], + loc: { + start: { column: 18, line: 5 }, + end: { column: 19, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [85, 86], + loc: { + start: { column: 20, line: 5 }, + end: { column: 21, line: 5 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "+", + + range: [89, 90], + loc: { + start: { column: 2, line: 6 }, + end: { column: 3, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [90, 98], + loc: { + start: { column: 3, line: 6 }, + end: { column: 11, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [99, 100], + loc: { + start: { column: 12, line: 6 }, + end: { column: 13, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [100, 101], + loc: { + start: { column: 13, line: 6 }, + end: { column: 14, line: 6 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [102, 104], + loc: { + start: { column: 15, line: 6 }, + end: { column: 17, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [105, 111], + loc: { + start: { column: 18, line: 6 }, + end: { column: 24, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [111, 112], + loc: { + start: { column: 24, line: 6 }, + end: { column: 25, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [112, 113], + loc: { + start: { column: 25, line: 6 }, + end: { column: 26, line: 6 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [114, 120], + loc: { + start: { column: 27, line: 6 }, + end: { column: 33, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [120, 121], + loc: { + start: { column: 33, line: 6 }, + end: { column: 34, line: 6 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [122, 123], + loc: { + start: { column: 0, line: 7 }, + end: { column: 1, line: 7 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [123, 124], + loc: { + start: { column: 1, line: 7 }, + end: { column: 2, line: 7 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [126, 130], + loc: { + start: { column: 0, line: 9 }, + end: { column: 4, line: 9 }, + }, + }, + Identifier { + type: "Identifier", + value: "MinusReadonlyOptional", + + range: [131, 152], + loc: { + start: { column: 5, line: 9 }, + end: { column: 26, line: 9 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [153, 154], + loc: { + start: { column: 27, line: 9 }, + end: { column: 28, line: 9 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [155, 156], + loc: { + start: { column: 29, line: 9 }, + end: { column: 30, line: 9 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "-", + + range: [159, 160], + loc: { + start: { column: 2, line: 10 }, + end: { column: 3, line: 10 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [160, 168], + loc: { + start: { column: 3, line: 10 }, + end: { column: 11, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [169, 170], + loc: { + start: { column: 12, line: 10 }, + end: { column: 13, line: 10 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [170, 171], + loc: { + start: { column: 13, line: 10 }, + end: { column: 14, line: 10 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [172, 174], + loc: { + start: { column: 15, line: 10 }, + end: { column: 17, line: 10 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [175, 181], + loc: { + start: { column: 18, line: 10 }, + end: { column: 24, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [181, 182], + loc: { + start: { column: 24, line: 10 }, + end: { column: 25, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "-", + + range: [182, 183], + loc: { + start: { column: 25, line: 10 }, + end: { column: 26, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [183, 184], + loc: { + start: { column: 26, line: 10 }, + end: { column: 27, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [184, 185], + loc: { + start: { column: 27, line: 10 }, + end: { column: 28, line: 10 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [186, 192], + loc: { + start: { column: 29, line: 10 }, + end: { column: 35, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [192, 193], + loc: { + start: { column: 35, line: 10 }, + end: { column: 36, line: 10 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [194, 195], + loc: { + start: { column: 0, line: 11 }, + end: { column: 1, line: 11 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [195, 196], + loc: { + start: { column: 1, line: 11 }, + end: { column: 2, line: 11 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..b77dc65ba8cd --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,268 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > with-modifiers > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'ReadonlyOptional', +- optional: false, + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [43, 49], +- loc: { +- start: { column: 17, line: 2 }, +- end: { column: 23, line: 2 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [38, 39], +- loc: { +- start: { column: 12, line: 2 }, +- end: { column: 13, line: 2 }, +- }, +- }, + nameType: null, + optional: true, + readonly: true, + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', + ++ range: [43, 49], ++ loc: { ++ start: { column: 17, line: 2 }, ++ end: { column: 23, line: 2 }, ++ }, ++ }, ++ name: 'P', ++ ++ range: [38, 49], ++ loc: { ++ start: { column: 12, line: 2 }, ++ end: { column: 23, line: 2 }, ++ }, ++ }, ++ + range: [24, 62], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 63], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'PlusReadonly', +- optional: false, + + range: [70, 82], + loc: { + start: { column: 5, line: 5 }, + end: { column: 17, line: 5 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [105, 111], +- loc: { +- start: { column: 18, line: 6 }, +- end: { column: 24, line: 6 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [100, 101], +- loc: { +- start: { column: 13, line: 6 }, +- end: { column: 14, line: 6 }, +- }, +- }, + nameType: null, +- optional: false, + readonly: '+', + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [114, 120], + loc: { + start: { column: 27, line: 6 }, + end: { column: 33, line: 6 }, ++ }, ++ }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', ++ ++ range: [105, 111], ++ loc: { ++ start: { column: 18, line: 6 }, ++ end: { column: 24, line: 6 }, ++ }, ++ }, ++ name: 'P', ++ ++ range: [100, 111], ++ loc: { ++ start: { column: 13, line: 6 }, ++ end: { column: 24, line: 6 }, + }, + }, + + range: [85, 123], + loc: { + start: { column: 20, line: 5 }, + end: { column: 1, line: 7 }, + }, + }, + + range: [65, 124], + loc: { + start: { column: 0, line: 5 }, + end: { column: 2, line: 7 }, + }, + }, + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'MinusReadonlyOptional', +- optional: false, + + range: [131, 152], + loc: { + start: { column: 5, line: 9 }, + end: { column: 26, line: 9 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [175, 181], +- loc: { +- start: { column: 18, line: 10 }, +- end: { column: 24, line: 10 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [170, 171], +- loc: { +- start: { column: 13, line: 10 }, +- end: { column: 14, line: 10 }, +- }, +- }, + nameType: null, + optional: '-', + readonly: '-', + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [186, 192], + loc: { + start: { column: 29, line: 10 }, + end: { column: 35, line: 10 }, ++ }, ++ }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', ++ ++ range: [175, 181], ++ loc: { ++ start: { column: 18, line: 10 }, ++ end: { column: 24, line: 10 }, ++ }, ++ }, ++ name: 'P', ++ ++ range: [170, 181], ++ loc: { ++ start: { column: 13, line: 10 }, ++ end: { column: 24, line: 10 }, + }, + }, + + range: [155, 195], + loc: { + start: { column: 29, line: 9 }, + end: { column: 1, line: 11 }, + }, + }, + + range: [126, 196], + loc: { + start: { column: 0, line: 9 }, + end: { column: 2, line: 11 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 197], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 12 }, + }, + } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..81306e4f2605 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,5 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > with-modifiers > AST Alignment - Token`] +Snapshot Diff: +Compared values have no visual difference. diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot index 77762c062843..175b19dbcd1c 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-ast.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot @@ -524,5 +524,8 @@ 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/fixture.ts", + "type/TSMappedType/fixtures/base/fixture.ts", + "type/TSMappedType/fixtures/no-modifiers/fixture.ts", + "type/TSMappedType/fixtures/with-modifiers/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..0e59d2ed8cda 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot @@ -134,5 +134,6 @@ 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/fixture.ts", + "type/TSMappedType/fixtures/base/fixture.ts" ] From 3003d899e79378817128cb09148988c774b70c6a Mon Sep 17 00:00:00 2001 From: bradzacher Date: Mon, 5 May 2025 12:09:52 +0930 Subject: [PATCH 07/12] split fixtures --- .../with-modifiers-readonly-minus/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 76 +++ .../snapshots/2-TSESTree-Tokens.shot | 172 ++++++ .../snapshots/3-Babel-AST.shot | 71 +++ .../snapshots/4-Babel-Tokens.shot | 172 ++++++ .../snapshots/5-AST-Alignment-AST.shot | 102 ++++ .../snapshots/6-AST-Alignment-Tokens.shot | 5 + .../with-modifiers-readonly-plus/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 76 +++ .../snapshots/2-TSESTree-Tokens.shot | 162 ++++++ .../snapshots/3-Babel-AST.shot | 70 +++ .../snapshots/4-Babel-Tokens.shot | 162 ++++++ .../snapshots/5-AST-Alignment-AST.shot | 102 ++++ .../snapshots/6-AST-Alignment-Tokens.shot | 5 + .../with-modifiers-readonly/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 76 +++ .../snapshots/2-TSESTree-Tokens.shot | 162 ++++++ .../snapshots/3-Babel-AST.shot | 71 +++ .../snapshots/4-Babel-Tokens.shot | 162 ++++++ .../snapshots/5-AST-Alignment-AST.shot | 102 ++++ .../snapshots/6-AST-Alignment-Tokens.shot | 2 +- .../fixtures/with-modifiers/fixture.ts | 11 - .../snapshots/1-TSESTree-AST.shot | 204 ------- .../snapshots/2-TSESTree-Tokens.shot | 502 ------------------ .../with-modifiers/snapshots/3-Babel-AST.shot | 188 ------- .../snapshots/4-Babel-Tokens.shot | 502 ------------------ .../snapshots/5-AST-Alignment-AST.shot | 268 ---------- .../tests/fixtures-with-differences-ast.shot | 4 +- 28 files changed, 1761 insertions(+), 1677 deletions(-) create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/fixture.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/fixture.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/fixture.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/5-AST-Alignment-AST.shot rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers => with-modifiers-readonly}/snapshots/6-AST-Alignment-Tokens.shot (55%) delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/fixture.ts delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/1-TSESTree-AST.shot delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/2-TSESTree-Tokens.shot delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/3-Babel-AST.shot delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/4-Babel-Tokens.shot delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/5-AST-Alignment-AST.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/fixture.ts new file mode 100644 index 000000000000..5303452d1094 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/fixture.ts @@ -0,0 +1,3 @@ +type ReadonlyOptional = { + -readonly [P in string]?: number; +}; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..76b04f7c6f1c --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,76 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "ReadonlyOptional", + optional: false, + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [44, 50], + loc: { + start: { column: 18, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [39, 40], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + nameType: null, + optional: true, + readonly: "-", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [54, 60], + loc: { + start: { column: 28, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + + range: [24, 63], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 64], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 65], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..1d219ddc3a3b --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,172 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "-", + + range: [28, 29], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [29, 37], + loc: { + start: { column: 3, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [39, 40], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [41, 43], + loc: { + start: { column: 15, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [44, 50], + loc: { + start: { column: 18, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [50, 51], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [51, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [52, 53], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [54, 60], + loc: { + start: { column: 28, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [60, 61], + loc: { + start: { column: 34, line: 2 }, + end: { column: 35, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [62, 63], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [63, 64], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..4520f235a393 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/3-Babel-AST.shot @@ -0,0 +1,71 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + optional: true, + readonly: "-", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [54, 60], + loc: { + start: { column: 28, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [44, 50], + loc: { + start: { column: 18, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + name: "P", + + range: [39, 50], + loc: { + start: { column: 13, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + + range: [24, 63], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 64], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 65], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..1d219ddc3a3b --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,172 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "-", + + range: [28, 29], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [29, 37], + loc: { + start: { column: 3, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [39, 40], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [41, 43], + loc: { + start: { column: 15, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [44, 50], + loc: { + start: { column: 18, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [50, 51], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [51, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [52, 53], + loc: { + start: { column: 26, line: 2 }, + end: { column: 27, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [54, 60], + loc: { + start: { column: 28, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [60, 61], + loc: { + start: { column: 34, line: 2 }, + end: { column: 35, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [62, 63], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [63, 64], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..77f6e5412683 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,102 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly-minus > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'ReadonlyOptional', +- optional: false, + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [44, 50], +- loc: { +- start: { column: 18, line: 2 }, +- end: { column: 24, line: 2 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [39, 40], +- loc: { +- start: { column: 13, line: 2 }, +- end: { column: 14, line: 2 }, +- }, +- }, + nameType: null, + optional: true, + readonly: '-', + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [54, 60], + loc: { + start: { column: 28, line: 2 }, + end: { column: 34, line: 2 }, ++ }, ++ }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', ++ ++ range: [44, 50], ++ loc: { ++ start: { column: 18, line: 2 }, ++ end: { column: 24, line: 2 }, ++ }, ++ }, ++ name: 'P', ++ ++ range: [39, 50], ++ loc: { ++ start: { column: 13, line: 2 }, ++ end: { column: 24, line: 2 }, + }, + }, + + range: [24, 63], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 64], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 65], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..7bf5784d4a05 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,5 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly-minus > AST Alignment - Token`] +Snapshot Diff: +Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/fixture.ts new file mode 100644 index 000000000000..cac84c242209 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/fixture.ts @@ -0,0 +1,3 @@ +type PlusReadonly = { + +readonly [P in string]: number; +}; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..cd70d426838d --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,76 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "PlusReadonly", + optional: false, + + range: [5, 17], + loc: { + start: { column: 5, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [40, 46], + loc: { + start: { column: 18, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [35, 36], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + nameType: null, + optional: false, + readonly: "+", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [49, 55], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + + range: [20, 58], + loc: { + start: { column: 20, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 59], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 60], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..6705b1f3585f --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,162 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "PlusReadonly", + + range: [5, 17], + loc: { + start: { column: 5, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "+", + + range: [24, 25], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [25, 33], + loc: { + start: { column: 3, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [34, 35], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [35, 36], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [37, 39], + loc: { + start: { column: 15, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [40, 46], + loc: { + start: { column: 18, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [46, 47], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [47, 48], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [49, 55], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [55, 56], + loc: { + start: { column: 33, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [57, 58], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [58, 59], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..cf6c86c51b3b --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/3-Babel-AST.shot @@ -0,0 +1,70 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "PlusReadonly", + + range: [5, 17], + loc: { + start: { column: 5, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + readonly: "+", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [49, 55], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [40, 46], + loc: { + start: { column: 18, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + name: "P", + + range: [35, 46], + loc: { + start: { column: 13, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + + range: [20, 58], + loc: { + start: { column: 20, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 59], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 60], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..6705b1f3585f --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,162 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "PlusReadonly", + + range: [5, 17], + loc: { + start: { column: 5, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "+", + + range: [24, 25], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [25, 33], + loc: { + start: { column: 3, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [34, 35], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [35, 36], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [37, 39], + loc: { + start: { column: 15, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [40, 46], + loc: { + start: { column: 18, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [46, 47], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [47, 48], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [49, 55], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [55, 56], + loc: { + start: { column: 33, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [57, 58], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [58, 59], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..13e2da0777fe --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,102 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly-plus > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'PlusReadonly', +- optional: false, + + range: [5, 17], + loc: { + start: { column: 5, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [40, 46], +- loc: { +- start: { column: 18, line: 2 }, +- end: { column: 24, line: 2 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [35, 36], +- loc: { +- start: { column: 13, line: 2 }, +- end: { column: 14, line: 2 }, +- }, +- }, + nameType: null, +- optional: false, + readonly: '+', + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [49, 55], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, ++ }, ++ }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', ++ ++ range: [40, 46], ++ loc: { ++ start: { column: 18, line: 2 }, ++ end: { column: 24, line: 2 }, ++ }, ++ }, ++ name: 'P', ++ ++ range: [35, 46], ++ loc: { ++ start: { column: 13, line: 2 }, ++ end: { column: 24, line: 2 }, + }, + }, + + range: [20, 58], + loc: { + start: { column: 20, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 59], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 60], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..5b52d7e4624e --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,5 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly-plus > AST Alignment - Token`] +Snapshot Diff: +Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/fixture.ts new file mode 100644 index 000000000000..f6774b5d317e --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/fixture.ts @@ -0,0 +1,3 @@ +type ReadonlyOptional = { + readonly [P in string]?: number; +}; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..ce3b5b1785e9 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,76 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "ReadonlyOptional", + optional: false, + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + nameType: null, + optional: true, + readonly: true, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + + range: [24, 62], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 63], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 64], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..1dc2635c20ca --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,162 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [28, 36], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [37, 38], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [40, 42], + loc: { + start: { column: 14, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [49, 50], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [50, 51], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [51, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [59, 60], + loc: { + start: { column: 33, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [61, 62], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [62, 63], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..dcba1b68e86f --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/3-Babel-AST.shot @@ -0,0 +1,71 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + optional: true, + readonly: true, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + name: "P", + + range: [38, 49], + loc: { + start: { column: 12, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + + range: [24, 62], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 63], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 64], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..1dc2635c20ca --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,162 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [28, 36], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [37, 38], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [40, 42], + loc: { + start: { column: 14, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [49, 50], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [50, 51], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [51, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [59, 60], + loc: { + start: { column: 33, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [61, 62], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [62, 63], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..68c7e8a9ff0f --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,102 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'ReadonlyOptional', +- optional: false, + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [43, 49], +- loc: { +- start: { column: 17, line: 2 }, +- end: { column: 23, line: 2 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [38, 39], +- loc: { +- start: { column: 12, line: 2 }, +- end: { column: 13, line: 2 }, +- }, +- }, + nameType: null, + optional: true, + readonly: true, + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, ++ }, ++ }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', ++ ++ range: [43, 49], ++ loc: { ++ start: { column: 17, line: 2 }, ++ end: { column: 23, line: 2 }, ++ }, ++ }, ++ name: 'P', ++ ++ range: [38, 49], ++ loc: { ++ start: { column: 12, line: 2 }, ++ end: { column: 23, line: 2 }, + }, + }, + + range: [24, 62], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 63], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 64], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/6-AST-Alignment-Tokens.shot similarity index 55% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/6-AST-Alignment-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/6-AST-Alignment-Tokens.shot index 81306e4f2605..2bd890ccf742 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/6-AST-Alignment-Tokens.shot @@ -1,5 +1,5 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > with-modifiers > AST Alignment - Token`] +exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly > AST Alignment - Token`] Snapshot Diff: Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/fixture.ts deleted file mode 100644 index b2f2e7c41654..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/fixture.ts +++ /dev/null @@ -1,11 +0,0 @@ -type ReadonlyOptional = { - readonly [P in string]?: number; -}; - -type PlusReadonly = { - +readonly [P in string]: number; -}; - -type MinusReadonlyOptional = { - -readonly [P in string]-?: number; -}; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/1-TSESTree-AST.shot deleted file mode 100644 index ac5c50a2629c..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/1-TSESTree-AST.shot +++ /dev/null @@ -1,204 +0,0 @@ -Program { - type: "Program", - body: [ - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - declare: false, - id: Identifier { - type: "Identifier", - decorators: [], - name: "ReadonlyOptional", - optional: false, - - range: [5, 21], - loc: { - start: { column: 5, line: 1 }, - end: { column: 21, line: 1 }, - }, - }, - typeAnnotation: TSMappedType { - type: "TSMappedType", - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [43, 49], - loc: { - start: { column: 17, line: 2 }, - end: { column: 23, line: 2 }, - }, - }, - key: Identifier { - type: "Identifier", - decorators: [], - name: "P", - optional: false, - - range: [38, 39], - loc: { - start: { column: 12, line: 2 }, - end: { column: 13, line: 2 }, - }, - }, - nameType: null, - optional: true, - readonly: true, - typeAnnotation: TSNumberKeyword { - type: "TSNumberKeyword", - - range: [53, 59], - loc: { - start: { column: 27, line: 2 }, - end: { column: 33, line: 2 }, - }, - }, - - range: [24, 62], - loc: { - start: { column: 24, line: 1 }, - end: { column: 1, line: 3 }, - }, - }, - - range: [0, 63], - loc: { - start: { column: 0, line: 1 }, - end: { column: 2, line: 3 }, - }, - }, - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - declare: false, - id: Identifier { - type: "Identifier", - decorators: [], - name: "PlusReadonly", - optional: false, - - range: [70, 82], - loc: { - start: { column: 5, line: 5 }, - end: { column: 17, line: 5 }, - }, - }, - typeAnnotation: TSMappedType { - type: "TSMappedType", - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [105, 111], - loc: { - start: { column: 18, line: 6 }, - end: { column: 24, line: 6 }, - }, - }, - key: Identifier { - type: "Identifier", - decorators: [], - name: "P", - optional: false, - - range: [100, 101], - loc: { - start: { column: 13, line: 6 }, - end: { column: 14, line: 6 }, - }, - }, - nameType: null, - optional: false, - readonly: "+", - typeAnnotation: TSNumberKeyword { - type: "TSNumberKeyword", - - range: [114, 120], - loc: { - start: { column: 27, line: 6 }, - end: { column: 33, line: 6 }, - }, - }, - - range: [85, 123], - loc: { - start: { column: 20, line: 5 }, - end: { column: 1, line: 7 }, - }, - }, - - range: [65, 124], - loc: { - start: { column: 0, line: 5 }, - end: { column: 2, line: 7 }, - }, - }, - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - declare: false, - id: Identifier { - type: "Identifier", - decorators: [], - name: "MinusReadonlyOptional", - optional: false, - - range: [131, 152], - loc: { - start: { column: 5, line: 9 }, - end: { column: 26, line: 9 }, - }, - }, - typeAnnotation: TSMappedType { - type: "TSMappedType", - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [175, 181], - loc: { - start: { column: 18, line: 10 }, - end: { column: 24, line: 10 }, - }, - }, - key: Identifier { - type: "Identifier", - decorators: [], - name: "P", - optional: false, - - range: [170, 171], - loc: { - start: { column: 13, line: 10 }, - end: { column: 14, line: 10 }, - }, - }, - nameType: null, - optional: "-", - readonly: "-", - typeAnnotation: TSNumberKeyword { - type: "TSNumberKeyword", - - range: [186, 192], - loc: { - start: { column: 29, line: 10 }, - end: { column: 35, line: 10 }, - }, - }, - - range: [155, 195], - loc: { - start: { column: 29, line: 9 }, - end: { column: 1, line: 11 }, - }, - }, - - range: [126, 196], - loc: { - start: { column: 0, line: 9 }, - end: { column: 2, line: 11 }, - }, - }, - ], - sourceType: "script", - - range: [0, 197], - loc: { - start: { column: 0, line: 1 }, - end: { column: 0, line: 12 }, - }, -} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/2-TSESTree-Tokens.shot deleted file mode 100644 index d76c84b19633..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/2-TSESTree-Tokens.shot +++ /dev/null @@ -1,502 +0,0 @@ -[ - Identifier { - type: "Identifier", - value: "type", - - range: [0, 4], - loc: { - start: { column: 0, line: 1 }, - end: { column: 4, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "ReadonlyOptional", - - range: [5, 21], - loc: { - start: { column: 5, line: 1 }, - end: { column: 21, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "=", - - range: [22, 23], - loc: { - start: { column: 22, line: 1 }, - end: { column: 23, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [24, 25], - loc: { - start: { column: 24, line: 1 }, - end: { column: 25, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "readonly", - - range: [28, 36], - loc: { - start: { column: 2, line: 2 }, - end: { column: 10, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "[", - - range: [37, 38], - loc: { - start: { column: 11, line: 2 }, - end: { column: 12, line: 2 }, - }, - }, - Identifier { - type: "Identifier", - value: "P", - - range: [38, 39], - loc: { - start: { column: 12, line: 2 }, - end: { column: 13, line: 2 }, - }, - }, - Keyword { - type: "Keyword", - value: "in", - - range: [40, 42], - loc: { - start: { column: 14, line: 2 }, - end: { column: 16, line: 2 }, - }, - }, - Identifier { - type: "Identifier", - value: "string", - - range: [43, 49], - loc: { - start: { column: 17, line: 2 }, - end: { column: 23, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "]", - - range: [49, 50], - loc: { - start: { column: 23, line: 2 }, - end: { column: 24, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "?", - - range: [50, 51], - loc: { - start: { column: 24, line: 2 }, - end: { column: 25, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [51, 52], - loc: { - start: { column: 25, line: 2 }, - end: { column: 26, line: 2 }, - }, - }, - Identifier { - type: "Identifier", - value: "number", - - range: [53, 59], - loc: { - start: { column: 27, line: 2 }, - end: { column: 33, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [59, 60], - loc: { - start: { column: 33, line: 2 }, - end: { column: 34, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [61, 62], - loc: { - start: { column: 0, line: 3 }, - end: { column: 1, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [62, 63], - loc: { - start: { column: 1, line: 3 }, - end: { column: 2, line: 3 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [65, 69], - loc: { - start: { column: 0, line: 5 }, - end: { column: 4, line: 5 }, - }, - }, - Identifier { - type: "Identifier", - value: "PlusReadonly", - - range: [70, 82], - loc: { - start: { column: 5, line: 5 }, - end: { column: 17, line: 5 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "=", - - range: [83, 84], - loc: { - start: { column: 18, line: 5 }, - end: { column: 19, line: 5 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [85, 86], - loc: { - start: { column: 20, line: 5 }, - end: { column: 21, line: 5 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "+", - - range: [89, 90], - loc: { - start: { column: 2, line: 6 }, - end: { column: 3, line: 6 }, - }, - }, - Identifier { - type: "Identifier", - value: "readonly", - - range: [90, 98], - loc: { - start: { column: 3, line: 6 }, - end: { column: 11, line: 6 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "[", - - range: [99, 100], - loc: { - start: { column: 12, line: 6 }, - end: { column: 13, line: 6 }, - }, - }, - Identifier { - type: "Identifier", - value: "P", - - range: [100, 101], - loc: { - start: { column: 13, line: 6 }, - end: { column: 14, line: 6 }, - }, - }, - Keyword { - type: "Keyword", - value: "in", - - range: [102, 104], - loc: { - start: { column: 15, line: 6 }, - end: { column: 17, line: 6 }, - }, - }, - Identifier { - type: "Identifier", - value: "string", - - range: [105, 111], - loc: { - start: { column: 18, line: 6 }, - end: { column: 24, line: 6 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "]", - - range: [111, 112], - loc: { - start: { column: 24, line: 6 }, - end: { column: 25, line: 6 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [112, 113], - loc: { - start: { column: 25, line: 6 }, - end: { column: 26, line: 6 }, - }, - }, - Identifier { - type: "Identifier", - value: "number", - - range: [114, 120], - loc: { - start: { column: 27, line: 6 }, - end: { column: 33, line: 6 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [120, 121], - loc: { - start: { column: 33, line: 6 }, - end: { column: 34, line: 6 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [122, 123], - loc: { - start: { column: 0, line: 7 }, - end: { column: 1, line: 7 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [123, 124], - loc: { - start: { column: 1, line: 7 }, - end: { column: 2, line: 7 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [126, 130], - loc: { - start: { column: 0, line: 9 }, - end: { column: 4, line: 9 }, - }, - }, - Identifier { - type: "Identifier", - value: "MinusReadonlyOptional", - - range: [131, 152], - loc: { - start: { column: 5, line: 9 }, - end: { column: 26, line: 9 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "=", - - range: [153, 154], - loc: { - start: { column: 27, line: 9 }, - end: { column: 28, line: 9 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [155, 156], - loc: { - start: { column: 29, line: 9 }, - end: { column: 30, line: 9 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "-", - - range: [159, 160], - loc: { - start: { column: 2, line: 10 }, - end: { column: 3, line: 10 }, - }, - }, - Identifier { - type: "Identifier", - value: "readonly", - - range: [160, 168], - loc: { - start: { column: 3, line: 10 }, - end: { column: 11, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "[", - - range: [169, 170], - loc: { - start: { column: 12, line: 10 }, - end: { column: 13, line: 10 }, - }, - }, - Identifier { - type: "Identifier", - value: "P", - - range: [170, 171], - loc: { - start: { column: 13, line: 10 }, - end: { column: 14, line: 10 }, - }, - }, - Keyword { - type: "Keyword", - value: "in", - - range: [172, 174], - loc: { - start: { column: 15, line: 10 }, - end: { column: 17, line: 10 }, - }, - }, - Identifier { - type: "Identifier", - value: "string", - - range: [175, 181], - loc: { - start: { column: 18, line: 10 }, - end: { column: 24, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "]", - - range: [181, 182], - loc: { - start: { column: 24, line: 10 }, - end: { column: 25, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "-", - - range: [182, 183], - loc: { - start: { column: 25, line: 10 }, - end: { column: 26, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "?", - - range: [183, 184], - loc: { - start: { column: 26, line: 10 }, - end: { column: 27, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [184, 185], - loc: { - start: { column: 27, line: 10 }, - end: { column: 28, line: 10 }, - }, - }, - Identifier { - type: "Identifier", - value: "number", - - range: [186, 192], - loc: { - start: { column: 29, line: 10 }, - end: { column: 35, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [192, 193], - loc: { - start: { column: 35, line: 10 }, - end: { column: 36, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [194, 195], - loc: { - start: { column: 0, line: 11 }, - end: { column: 1, line: 11 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [195, 196], - loc: { - start: { column: 1, line: 11 }, - end: { column: 2, line: 11 }, - }, - }, -] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/3-Babel-AST.shot deleted file mode 100644 index cc364f2de4ec..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/3-Babel-AST.shot +++ /dev/null @@ -1,188 +0,0 @@ -Program { - type: "Program", - body: [ - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - id: Identifier { - type: "Identifier", - name: "ReadonlyOptional", - - range: [5, 21], - loc: { - start: { column: 5, line: 1 }, - end: { column: 21, line: 1 }, - }, - }, - typeAnnotation: TSMappedType { - type: "TSMappedType", - nameType: null, - optional: true, - readonly: true, - typeAnnotation: TSNumberKeyword { - type: "TSNumberKeyword", - - range: [53, 59], - loc: { - start: { column: 27, line: 2 }, - end: { column: 33, line: 2 }, - }, - }, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [43, 49], - loc: { - start: { column: 17, line: 2 }, - end: { column: 23, line: 2 }, - }, - }, - name: "P", - - range: [38, 49], - loc: { - start: { column: 12, line: 2 }, - end: { column: 23, line: 2 }, - }, - }, - - range: [24, 62], - loc: { - start: { column: 24, line: 1 }, - end: { column: 1, line: 3 }, - }, - }, - - range: [0, 63], - loc: { - start: { column: 0, line: 1 }, - end: { column: 2, line: 3 }, - }, - }, - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - id: Identifier { - type: "Identifier", - name: "PlusReadonly", - - range: [70, 82], - loc: { - start: { column: 5, line: 5 }, - end: { column: 17, line: 5 }, - }, - }, - typeAnnotation: TSMappedType { - type: "TSMappedType", - nameType: null, - readonly: "+", - typeAnnotation: TSNumberKeyword { - type: "TSNumberKeyword", - - range: [114, 120], - loc: { - start: { column: 27, line: 6 }, - end: { column: 33, line: 6 }, - }, - }, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [105, 111], - loc: { - start: { column: 18, line: 6 }, - end: { column: 24, line: 6 }, - }, - }, - name: "P", - - range: [100, 111], - loc: { - start: { column: 13, line: 6 }, - end: { column: 24, line: 6 }, - }, - }, - - range: [85, 123], - loc: { - start: { column: 20, line: 5 }, - end: { column: 1, line: 7 }, - }, - }, - - range: [65, 124], - loc: { - start: { column: 0, line: 5 }, - end: { column: 2, line: 7 }, - }, - }, - TSTypeAliasDeclaration { - type: "TSTypeAliasDeclaration", - id: Identifier { - type: "Identifier", - name: "MinusReadonlyOptional", - - range: [131, 152], - loc: { - start: { column: 5, line: 9 }, - end: { column: 26, line: 9 }, - }, - }, - typeAnnotation: TSMappedType { - type: "TSMappedType", - nameType: null, - optional: "-", - readonly: "-", - typeAnnotation: TSNumberKeyword { - type: "TSNumberKeyword", - - range: [186, 192], - loc: { - start: { column: 29, line: 10 }, - end: { column: 35, line: 10 }, - }, - }, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [175, 181], - loc: { - start: { column: 18, line: 10 }, - end: { column: 24, line: 10 }, - }, - }, - name: "P", - - range: [170, 181], - loc: { - start: { column: 13, line: 10 }, - end: { column: 24, line: 10 }, - }, - }, - - range: [155, 195], - loc: { - start: { column: 29, line: 9 }, - end: { column: 1, line: 11 }, - }, - }, - - range: [126, 196], - loc: { - start: { column: 0, line: 9 }, - end: { column: 2, line: 11 }, - }, - }, - ], - sourceType: "script", - - range: [0, 197], - loc: { - start: { column: 0, line: 1 }, - end: { column: 0, line: 12 }, - }, -} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/4-Babel-Tokens.shot deleted file mode 100644 index d76c84b19633..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/4-Babel-Tokens.shot +++ /dev/null @@ -1,502 +0,0 @@ -[ - Identifier { - type: "Identifier", - value: "type", - - range: [0, 4], - loc: { - start: { column: 0, line: 1 }, - end: { column: 4, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "ReadonlyOptional", - - range: [5, 21], - loc: { - start: { column: 5, line: 1 }, - end: { column: 21, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "=", - - range: [22, 23], - loc: { - start: { column: 22, line: 1 }, - end: { column: 23, line: 1 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [24, 25], - loc: { - start: { column: 24, line: 1 }, - end: { column: 25, line: 1 }, - }, - }, - Identifier { - type: "Identifier", - value: "readonly", - - range: [28, 36], - loc: { - start: { column: 2, line: 2 }, - end: { column: 10, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "[", - - range: [37, 38], - loc: { - start: { column: 11, line: 2 }, - end: { column: 12, line: 2 }, - }, - }, - Identifier { - type: "Identifier", - value: "P", - - range: [38, 39], - loc: { - start: { column: 12, line: 2 }, - end: { column: 13, line: 2 }, - }, - }, - Keyword { - type: "Keyword", - value: "in", - - range: [40, 42], - loc: { - start: { column: 14, line: 2 }, - end: { column: 16, line: 2 }, - }, - }, - Identifier { - type: "Identifier", - value: "string", - - range: [43, 49], - loc: { - start: { column: 17, line: 2 }, - end: { column: 23, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "]", - - range: [49, 50], - loc: { - start: { column: 23, line: 2 }, - end: { column: 24, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "?", - - range: [50, 51], - loc: { - start: { column: 24, line: 2 }, - end: { column: 25, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [51, 52], - loc: { - start: { column: 25, line: 2 }, - end: { column: 26, line: 2 }, - }, - }, - Identifier { - type: "Identifier", - value: "number", - - range: [53, 59], - loc: { - start: { column: 27, line: 2 }, - end: { column: 33, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [59, 60], - loc: { - start: { column: 33, line: 2 }, - end: { column: 34, line: 2 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [61, 62], - loc: { - start: { column: 0, line: 3 }, - end: { column: 1, line: 3 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [62, 63], - loc: { - start: { column: 1, line: 3 }, - end: { column: 2, line: 3 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [65, 69], - loc: { - start: { column: 0, line: 5 }, - end: { column: 4, line: 5 }, - }, - }, - Identifier { - type: "Identifier", - value: "PlusReadonly", - - range: [70, 82], - loc: { - start: { column: 5, line: 5 }, - end: { column: 17, line: 5 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "=", - - range: [83, 84], - loc: { - start: { column: 18, line: 5 }, - end: { column: 19, line: 5 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [85, 86], - loc: { - start: { column: 20, line: 5 }, - end: { column: 21, line: 5 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "+", - - range: [89, 90], - loc: { - start: { column: 2, line: 6 }, - end: { column: 3, line: 6 }, - }, - }, - Identifier { - type: "Identifier", - value: "readonly", - - range: [90, 98], - loc: { - start: { column: 3, line: 6 }, - end: { column: 11, line: 6 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "[", - - range: [99, 100], - loc: { - start: { column: 12, line: 6 }, - end: { column: 13, line: 6 }, - }, - }, - Identifier { - type: "Identifier", - value: "P", - - range: [100, 101], - loc: { - start: { column: 13, line: 6 }, - end: { column: 14, line: 6 }, - }, - }, - Keyword { - type: "Keyword", - value: "in", - - range: [102, 104], - loc: { - start: { column: 15, line: 6 }, - end: { column: 17, line: 6 }, - }, - }, - Identifier { - type: "Identifier", - value: "string", - - range: [105, 111], - loc: { - start: { column: 18, line: 6 }, - end: { column: 24, line: 6 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "]", - - range: [111, 112], - loc: { - start: { column: 24, line: 6 }, - end: { column: 25, line: 6 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [112, 113], - loc: { - start: { column: 25, line: 6 }, - end: { column: 26, line: 6 }, - }, - }, - Identifier { - type: "Identifier", - value: "number", - - range: [114, 120], - loc: { - start: { column: 27, line: 6 }, - end: { column: 33, line: 6 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [120, 121], - loc: { - start: { column: 33, line: 6 }, - end: { column: 34, line: 6 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [122, 123], - loc: { - start: { column: 0, line: 7 }, - end: { column: 1, line: 7 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [123, 124], - loc: { - start: { column: 1, line: 7 }, - end: { column: 2, line: 7 }, - }, - }, - Identifier { - type: "Identifier", - value: "type", - - range: [126, 130], - loc: { - start: { column: 0, line: 9 }, - end: { column: 4, line: 9 }, - }, - }, - Identifier { - type: "Identifier", - value: "MinusReadonlyOptional", - - range: [131, 152], - loc: { - start: { column: 5, line: 9 }, - end: { column: 26, line: 9 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "=", - - range: [153, 154], - loc: { - start: { column: 27, line: 9 }, - end: { column: 28, line: 9 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "{", - - range: [155, 156], - loc: { - start: { column: 29, line: 9 }, - end: { column: 30, line: 9 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "-", - - range: [159, 160], - loc: { - start: { column: 2, line: 10 }, - end: { column: 3, line: 10 }, - }, - }, - Identifier { - type: "Identifier", - value: "readonly", - - range: [160, 168], - loc: { - start: { column: 3, line: 10 }, - end: { column: 11, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "[", - - range: [169, 170], - loc: { - start: { column: 12, line: 10 }, - end: { column: 13, line: 10 }, - }, - }, - Identifier { - type: "Identifier", - value: "P", - - range: [170, 171], - loc: { - start: { column: 13, line: 10 }, - end: { column: 14, line: 10 }, - }, - }, - Keyword { - type: "Keyword", - value: "in", - - range: [172, 174], - loc: { - start: { column: 15, line: 10 }, - end: { column: 17, line: 10 }, - }, - }, - Identifier { - type: "Identifier", - value: "string", - - range: [175, 181], - loc: { - start: { column: 18, line: 10 }, - end: { column: 24, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "]", - - range: [181, 182], - loc: { - start: { column: 24, line: 10 }, - end: { column: 25, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "-", - - range: [182, 183], - loc: { - start: { column: 25, line: 10 }, - end: { column: 26, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "?", - - range: [183, 184], - loc: { - start: { column: 26, line: 10 }, - end: { column: 27, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [184, 185], - loc: { - start: { column: 27, line: 10 }, - end: { column: 28, line: 10 }, - }, - }, - Identifier { - type: "Identifier", - value: "number", - - range: [186, 192], - loc: { - start: { column: 29, line: 10 }, - end: { column: 35, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [192, 193], - loc: { - start: { column: 35, line: 10 }, - end: { column: 36, line: 10 }, - }, - }, - Punctuator { - type: "Punctuator", - value: "}", - - range: [194, 195], - loc: { - start: { column: 0, line: 11 }, - end: { column: 1, line: 11 }, - }, - }, - Punctuator { - type: "Punctuator", - value: ";", - - range: [195, 196], - loc: { - start: { column: 1, line: 11 }, - end: { column: 2, line: 11 }, - }, - }, -] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/5-AST-Alignment-AST.shot deleted file mode 100644 index b77dc65ba8cd..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers/snapshots/5-AST-Alignment-AST.shot +++ /dev/null @@ -1,268 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`AST Fixtures > type > TSMappedType > with-modifiers > AST Alignment - AST`] -Snapshot Diff: -- TSESTree -+ Babel - - Program { - type: 'Program', - body: Array [ - TSTypeAliasDeclaration { - type: 'TSTypeAliasDeclaration', -- declare: false, - id: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'ReadonlyOptional', -- optional: false, - - range: [5, 21], - loc: { - start: { column: 5, line: 1 }, - end: { column: 21, line: 1 }, - }, - }, - typeAnnotation: TSMappedType { - type: 'TSMappedType', -- constraint: TSStringKeyword { -- type: 'TSStringKeyword', -- -- range: [43, 49], -- loc: { -- start: { column: 17, line: 2 }, -- end: { column: 23, line: 2 }, -- }, -- }, -- key: Identifier { -- type: 'Identifier', -- decorators: Array [], -- name: 'P', -- optional: false, -- -- range: [38, 39], -- loc: { -- start: { column: 12, line: 2 }, -- end: { column: 13, line: 2 }, -- }, -- }, - nameType: null, - optional: true, - readonly: true, - typeAnnotation: TSNumberKeyword { - type: 'TSNumberKeyword', - - range: [53, 59], - loc: { - start: { column: 27, line: 2 }, - end: { column: 33, line: 2 }, - }, - }, -+ typeParameter: TSTypeParameter { -+ type: 'TSTypeParameter', -+ constraint: TSStringKeyword { -+ type: 'TSStringKeyword', - -+ range: [43, 49], -+ loc: { -+ start: { column: 17, line: 2 }, -+ end: { column: 23, line: 2 }, -+ }, -+ }, -+ name: 'P', -+ -+ range: [38, 49], -+ loc: { -+ start: { column: 12, line: 2 }, -+ end: { column: 23, line: 2 }, -+ }, -+ }, -+ - range: [24, 62], - loc: { - start: { column: 24, line: 1 }, - end: { column: 1, line: 3 }, - }, - }, - - range: [0, 63], - loc: { - start: { column: 0, line: 1 }, - end: { column: 2, line: 3 }, - }, - }, - TSTypeAliasDeclaration { - type: 'TSTypeAliasDeclaration', -- declare: false, - id: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'PlusReadonly', -- optional: false, - - range: [70, 82], - loc: { - start: { column: 5, line: 5 }, - end: { column: 17, line: 5 }, - }, - }, - typeAnnotation: TSMappedType { - type: 'TSMappedType', -- constraint: TSStringKeyword { -- type: 'TSStringKeyword', -- -- range: [105, 111], -- loc: { -- start: { column: 18, line: 6 }, -- end: { column: 24, line: 6 }, -- }, -- }, -- key: Identifier { -- type: 'Identifier', -- decorators: Array [], -- name: 'P', -- optional: false, -- -- range: [100, 101], -- loc: { -- start: { column: 13, line: 6 }, -- end: { column: 14, line: 6 }, -- }, -- }, - nameType: null, -- optional: false, - readonly: '+', - typeAnnotation: TSNumberKeyword { - type: 'TSNumberKeyword', - - range: [114, 120], - loc: { - start: { column: 27, line: 6 }, - end: { column: 33, line: 6 }, -+ }, -+ }, -+ typeParameter: TSTypeParameter { -+ type: 'TSTypeParameter', -+ constraint: TSStringKeyword { -+ type: 'TSStringKeyword', -+ -+ range: [105, 111], -+ loc: { -+ start: { column: 18, line: 6 }, -+ end: { column: 24, line: 6 }, -+ }, -+ }, -+ name: 'P', -+ -+ range: [100, 111], -+ loc: { -+ start: { column: 13, line: 6 }, -+ end: { column: 24, line: 6 }, - }, - }, - - range: [85, 123], - loc: { - start: { column: 20, line: 5 }, - end: { column: 1, line: 7 }, - }, - }, - - range: [65, 124], - loc: { - start: { column: 0, line: 5 }, - end: { column: 2, line: 7 }, - }, - }, - TSTypeAliasDeclaration { - type: 'TSTypeAliasDeclaration', -- declare: false, - id: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'MinusReadonlyOptional', -- optional: false, - - range: [131, 152], - loc: { - start: { column: 5, line: 9 }, - end: { column: 26, line: 9 }, - }, - }, - typeAnnotation: TSMappedType { - type: 'TSMappedType', -- constraint: TSStringKeyword { -- type: 'TSStringKeyword', -- -- range: [175, 181], -- loc: { -- start: { column: 18, line: 10 }, -- end: { column: 24, line: 10 }, -- }, -- }, -- key: Identifier { -- type: 'Identifier', -- decorators: Array [], -- name: 'P', -- optional: false, -- -- range: [170, 171], -- loc: { -- start: { column: 13, line: 10 }, -- end: { column: 14, line: 10 }, -- }, -- }, - nameType: null, - optional: '-', - readonly: '-', - typeAnnotation: TSNumberKeyword { - type: 'TSNumberKeyword', - - range: [186, 192], - loc: { - start: { column: 29, line: 10 }, - end: { column: 35, line: 10 }, -+ }, -+ }, -+ typeParameter: TSTypeParameter { -+ type: 'TSTypeParameter', -+ constraint: TSStringKeyword { -+ type: 'TSStringKeyword', -+ -+ range: [175, 181], -+ loc: { -+ start: { column: 18, line: 10 }, -+ end: { column: 24, line: 10 }, -+ }, -+ }, -+ name: 'P', -+ -+ range: [170, 181], -+ loc: { -+ start: { column: 13, line: 10 }, -+ end: { column: 24, line: 10 }, - }, - }, - - range: [155, 195], - loc: { - start: { column: 29, line: 9 }, - end: { column: 1, line: 11 }, - }, - }, - - range: [126, 196], - loc: { - start: { column: 0, line: 9 }, - end: { column: 2, line: 11 }, - }, - }, - ], - sourceType: 'script', - - range: [0, 197], - loc: { - start: { column: 0, line: 1 }, - end: { column: 0, line: 12 }, - }, - } diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot index 175b19dbcd1c..279bf442416a 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-ast.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot @@ -527,5 +527,7 @@ exports[`AST Fixtures > List fixtures with AST differences`] "type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts", "type/TSMappedType/fixtures/base/fixture.ts", "type/TSMappedType/fixtures/no-modifiers/fixture.ts", - "type/TSMappedType/fixtures/with-modifiers/fixture.ts" + "type/TSMappedType/fixtures/with-modifiers-readonly-minus/fixture.ts", + "type/TSMappedType/fixtures/with-modifiers-readonly-plus/fixture.ts", + "type/TSMappedType/fixtures/with-modifiers-readonly/fixture.ts" ] From e14c50f4c1424adc2224d3214d988b2c6dd39a88 Mon Sep 17 00:00:00 2001 From: bradzacher Date: Mon, 5 May 2025 12:10:38 +0930 Subject: [PATCH 08/12] remove unit tests in favour of the fixture tests --- .../tests/lib/convert.test.ts | 74 ------------------- 1 file changed, 74 deletions(-) diff --git a/packages/typescript-estree/tests/lib/convert.test.ts b/packages/typescript-estree/tests/lib/convert.test.ts index dabf814b6b31..1473680fb8ec 100644 --- a/packages/typescript-estree/tests/lib/convert.test.ts +++ b/packages/typescript-estree/tests/lib/convert.test.ts @@ -449,79 +449,5 @@ describe('convert', () => { expect(tsMappedType.typeParameter).toBeUndefined(); expect(Object.keys(tsMappedType)).toContain('typeParameter'); }); - - describe('TSMappedType AST shape consistency', () => { - const getMappedTypeFromCode = (code: string): TSESTree.TSMappedType => { - const ast = convertCode(code); - const instance = new Converter(ast); - const program = instance.convertProgram(); - const varDec = program.body[0] as TSESTree.VariableDeclaration; - const typeAnnotation = varDec.declarations[0]?.id?.typeAnnotation; - if (!typeAnnotation) { - throw new Error('Type annotation is undefined'); - } - return typeAnnotation.typeAnnotation as TSESTree.TSMappedType; - }; - - it('should have optional=false when no optional modifier is present', () => { - const mappedType = getMappedTypeFromCode('var a: { [k in any]: any };'); - - expect(mappedType).toHaveProperty('optional', false); - }); - - it('should have optional=true when optional modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var b: { [k in any]?: any };', - ); - - expect(mappedType).toHaveProperty('optional', true); - }); - - it('should have readonly=undefined when no readonly modifier is present', () => { - const mappedType = getMappedTypeFromCode('var a: { [k in any]: any };'); - - expect(mappedType).toHaveProperty('readonly', undefined); - }); - - it('should have readonly=true when readonly modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var c: { readonly [k in any]: any };', - ); - - expect(mappedType).toHaveProperty('readonly', true); - }); - - it('should have readonly="+" when +readonly modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var d: { +readonly [k in any]: any };', - ); - - expect(mappedType).toHaveProperty('readonly', '+'); - }); - - it('should have readonly="-" when -readonly modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var e: { -readonly [k in any]: any };', - ); - - expect(mappedType).toHaveProperty('readonly', '-'); - }); - - it('should have optional="+" when +? modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var f: { [k in any]+?: any };', - ); - - expect(mappedType).toHaveProperty('optional', '+'); - }); - - it('should have optional="-" when -? modifier is present', () => { - const mappedType = getMappedTypeFromCode( - 'var g: { [k in any]-?: any };', - ); - - expect(mappedType).toHaveProperty('optional', '-'); - }); - }); }); }); From 76f693f99873de0567cf116fb09fc16f863afb9b Mon Sep 17 00:00:00 2001 From: bradzacher Date: Mon, 5 May 2025 12:14:26 +0930 Subject: [PATCH 09/12] add optional fixtures --- .../TSMappedType/fixtures/base/fixture.ts | 1 - .../base/snapshots/1-TSESTree-AST.shot | 98 ----------- .../fixtures/base/snapshots/3-Babel-AST.shot | 91 ---------- .../base/snapshots/5-AST-Alignment-AST.shot | 124 -------------- .../snapshots/6-AST-Alignment-Tokens.shot | 141 --------------- .../fixtures/optional-minus/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 75 ++++++++ .../snapshots/2-TSESTree-Tokens.shot | 96 +++++++---- .../optional-minus/snapshots/3-Babel-AST.shot | 70 ++++++++ .../snapshots/4-Babel-Tokens.shot | 92 ++++++---- .../snapshots/5-AST-Alignment-AST.shot | 101 +++++++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 5 + .../fixtures/optional-plus/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 75 ++++++++ .../snapshots/2-TSESTree-Tokens.shot | 162 ++++++++++++++++++ .../optional-plus/snapshots/3-Babel-AST.shot | 70 ++++++++ .../snapshots/4-Babel-Tokens.shot | 162 ++++++++++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 101 +++++++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 5 + .../TSMappedType/fixtures/optional/fixture.ts | 3 + .../optional/snapshots/1-TSESTree-AST.shot | 75 ++++++++ .../optional/snapshots/2-TSESTree-Tokens.shot | 162 ++++++++++++++++++ .../optional/snapshots/3-Babel-AST.shot | 70 ++++++++ .../optional/snapshots/4-Babel-Tokens.shot | 162 ++++++++++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 101 +++++++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 5 + .../fixture.ts | 0 .../snapshots/1-TSESTree-AST.shot | 0 .../snapshots/2-TSESTree-Tokens.shot | 0 .../snapshots/3-Babel-AST.shot | 0 .../snapshots/4-Babel-Tokens.shot | 0 .../snapshots/5-AST-Alignment-AST.shot | 0 .../snapshots/6-AST-Alignment-Tokens.shot | 0 .../fixture.ts | 0 .../snapshots/1-TSESTree-AST.shot | 0 .../snapshots/2-TSESTree-Tokens.shot | 0 .../snapshots/3-Babel-AST.shot | 0 .../snapshots/4-Babel-Tokens.shot | 0 .../snapshots/5-AST-Alignment-AST.shot | 0 .../snapshots/6-AST-Alignment-Tokens.shot | 0 .../fixture.ts | 0 .../snapshots/1-TSESTree-AST.shot | 0 .../snapshots/2-TSESTree-Tokens.shot | 0 .../snapshots/3-Babel-AST.shot | 0 .../snapshots/4-Babel-Tokens.shot | 0 .../snapshots/5-AST-Alignment-AST.shot | 0 .../snapshots/6-AST-Alignment-Tokens.shot | 0 .../tests/fixtures-with-differences-ast.shot | 4 +- .../fixtures-with-differences-tokens.shot | 3 +- 49 files changed, 1528 insertions(+), 532 deletions(-) delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/fixture.ts delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/1-TSESTree-AST.shot delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/3-Babel-AST.shot delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/5-AST-Alignment-AST.shot delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/fixture.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/1-TSESTree-AST.shot rename packages/ast-spec/src/type/TSMappedType/fixtures/{base => optional-minus}/snapshots/2-TSESTree-Tokens.shot (51%) create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/3-Babel-AST.shot rename packages/ast-spec/src/type/TSMappedType/fixtures/{base => optional-minus}/snapshots/4-Babel-Tokens.shot (53%) create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/fixture.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional/fixture.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/6-AST-Alignment-Tokens.shot rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-minus => readonly-minus}/fixture.ts (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-minus => readonly-minus}/snapshots/1-TSESTree-AST.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-minus => readonly-minus}/snapshots/2-TSESTree-Tokens.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-minus => readonly-minus}/snapshots/3-Babel-AST.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-minus => readonly-minus}/snapshots/4-Babel-Tokens.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-minus => readonly-minus}/snapshots/5-AST-Alignment-AST.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-minus => readonly-minus}/snapshots/6-AST-Alignment-Tokens.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-plus => readonly-plus}/fixture.ts (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-plus => readonly-plus}/snapshots/1-TSESTree-AST.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-plus => readonly-plus}/snapshots/2-TSESTree-Tokens.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-plus => readonly-plus}/snapshots/3-Babel-AST.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-plus => readonly-plus}/snapshots/4-Babel-Tokens.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-plus => readonly-plus}/snapshots/5-AST-Alignment-AST.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly-plus => readonly-plus}/snapshots/6-AST-Alignment-Tokens.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly => readonly}/fixture.ts (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly => readonly}/snapshots/1-TSESTree-AST.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly => readonly}/snapshots/2-TSESTree-Tokens.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly => readonly}/snapshots/3-Babel-AST.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly => readonly}/snapshots/4-Babel-Tokens.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly => readonly}/snapshots/5-AST-Alignment-AST.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/{with-modifiers-readonly => readonly}/snapshots/6-AST-Alignment-Tokens.shot (100%) diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/base/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/base/fixture.ts deleted file mode 100644 index 0482553071a0..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/base/fixture.ts +++ /dev/null @@ -1 +0,0 @@ -let map: { [P in string]: number }; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/1-TSESTree-AST.shot deleted file mode 100644 index a44ff979d52c..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/1-TSESTree-AST.shot +++ /dev/null @@ -1,98 +0,0 @@ -Program { - type: "Program", - body: [ - VariableDeclaration { - type: "VariableDeclaration", - declarations: [ - VariableDeclarator { - type: "VariableDeclarator", - definite: false, - id: Identifier { - type: "Identifier", - decorators: [], - name: "map", - optional: false, - typeAnnotation: TSTypeAnnotation { - type: "TSTypeAnnotation", - typeAnnotation: TSMappedType { - type: "TSMappedType", - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [17, 23], - loc: { - start: { column: 17, line: 1 }, - end: { column: 23, line: 1 }, - }, - }, - key: Identifier { - type: "Identifier", - decorators: [], - name: "P", - optional: false, - - range: [12, 13], - loc: { - start: { column: 12, line: 1 }, - end: { column: 13, line: 1 }, - }, - }, - nameType: null, - optional: false, - typeAnnotation: TSNumberKeyword { - type: "TSNumberKeyword", - - range: [26, 32], - loc: { - start: { column: 26, line: 1 }, - end: { column: 32, line: 1 }, - }, - }, - - range: [9, 34], - loc: { - start: { column: 9, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - - range: [7, 34], - loc: { - start: { column: 7, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - - range: [4, 34], - loc: { - start: { column: 4, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - init: null, - - range: [4, 34], - loc: { - start: { column: 4, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - ], - declare: false, - kind: "let", - - range: [0, 35], - loc: { - start: { column: 0, line: 1 }, - end: { column: 35, line: 1 }, - }, - }, - ], - sourceType: "script", - - range: [0, 36], - 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/TSMappedType/fixtures/base/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/3-Babel-AST.shot deleted file mode 100644 index 99fdaf143184..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/3-Babel-AST.shot +++ /dev/null @@ -1,91 +0,0 @@ -Program { - type: "Program", - body: [ - VariableDeclaration { - type: "VariableDeclaration", - declarations: [ - VariableDeclarator { - type: "VariableDeclarator", - id: Identifier { - type: "Identifier", - name: "map", - typeAnnotation: TSTypeAnnotation { - type: "TSTypeAnnotation", - typeAnnotation: TSMappedType { - type: "TSMappedType", - nameType: null, - typeAnnotation: TSNumberKeyword { - type: "TSNumberKeyword", - - range: [26, 32], - loc: { - start: { column: 26, line: 1 }, - end: { column: 32, line: 1 }, - }, - }, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [17, 23], - loc: { - start: { column: 17, line: 1 }, - end: { column: 23, line: 1 }, - }, - }, - name: "P", - - range: [12, 23], - loc: { - start: { column: 12, line: 1 }, - end: { column: 23, line: 1 }, - }, - }, - - range: [9, 34], - loc: { - start: { column: 9, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - - range: [7, 34], - loc: { - start: { column: 7, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - - range: [4, 34], - loc: { - start: { column: 4, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - init: null, - - range: [4, 34], - loc: { - start: { column: 4, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - ], - kind: "let", - - range: [0, 35], - loc: { - start: { column: 0, line: 1 }, - end: { column: 35, line: 1 }, - }, - }, - ], - sourceType: "script", - - range: [0, 36], - 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/TSMappedType/fixtures/base/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/5-AST-Alignment-AST.shot deleted file mode 100644 index c73767153f9d..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/5-AST-Alignment-AST.shot +++ /dev/null @@ -1,124 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`AST Fixtures > type > TSMappedType > base > AST Alignment - AST`] -Snapshot Diff: -- TSESTree -+ Babel - - Program { - type: 'Program', - body: Array [ - VariableDeclaration { - type: 'VariableDeclaration', - declarations: Array [ - VariableDeclarator { - type: 'VariableDeclarator', -- definite: false, - id: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'map', -- optional: false, - typeAnnotation: TSTypeAnnotation { - type: 'TSTypeAnnotation', - typeAnnotation: TSMappedType { - type: 'TSMappedType', -- constraint: TSStringKeyword { -- type: 'TSStringKeyword', -- -- range: [17, 23], -- loc: { -- start: { column: 17, line: 1 }, -- end: { column: 23, line: 1 }, -- }, -- }, -- key: Identifier { -- type: 'Identifier', -- decorators: Array [], -- name: 'P', -- optional: false, -- -- range: [12, 13], -- loc: { -- start: { column: 12, line: 1 }, -- end: { column: 13, line: 1 }, -- }, -- }, - nameType: null, -- optional: false, - typeAnnotation: TSNumberKeyword { - type: 'TSNumberKeyword', - - range: [26, 32], - loc: { - start: { column: 26, line: 1 }, - end: { column: 32, line: 1 }, -+ }, -+ }, -+ typeParameter: TSTypeParameter { -+ type: 'TSTypeParameter', -+ constraint: TSStringKeyword { -+ type: 'TSStringKeyword', -+ -+ range: [17, 23], -+ loc: { -+ start: { column: 17, line: 1 }, -+ end: { column: 23, line: 1 }, -+ }, -+ }, -+ name: 'P', -+ -+ range: [12, 23], -+ loc: { -+ start: { column: 12, line: 1 }, -+ end: { column: 23, line: 1 }, - }, - }, - - range: [9, 34], - loc: { - start: { column: 9, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - - range: [7, 34], - loc: { - start: { column: 7, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - - range: [4, 34], - loc: { - start: { column: 4, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - init: null, - - range: [4, 34], - loc: { - start: { column: 4, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - ], -- declare: false, - kind: 'let', - - range: [0, 35], - loc: { - start: { column: 0, line: 1 }, - end: { column: 35, line: 1 }, - }, - }, - ], - sourceType: 'script', - - range: [0, 36], - loc: { - start: { column: 0, line: 1 }, - end: { column: 0, line: 2 }, - }, - } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/6-AST-Alignment-Tokens.shot deleted file mode 100644 index 7b780c658454..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/6-AST-Alignment-Tokens.shot +++ /dev/null @@ -1,141 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`AST Fixtures > type > TSMappedType > base > AST Alignment - Token`] -Snapshot Diff: -- TSESTree -+ Babel - - Array [ -- Keyword { -- type: 'Keyword', -+ Identifier { -+ type: 'Identifier', - value: 'let', - - range: [0, 3], - loc: { - start: { column: 0, line: 1 }, - end: { column: 3, line: 1 }, - }, - }, - Identifier { - type: 'Identifier', - value: 'map', - - range: [4, 7], - loc: { - start: { column: 4, line: 1 }, - end: { column: 7, line: 1 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ':', - - range: [7, 8], - loc: { - start: { column: 7, line: 1 }, - end: { column: 8, line: 1 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '{', - - range: [9, 10], - loc: { - start: { column: 9, line: 1 }, - end: { column: 10, line: 1 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '[', - - range: [11, 12], - loc: { - start: { column: 11, line: 1 }, - end: { column: 12, line: 1 }, - }, - }, - Identifier { - type: 'Identifier', - value: 'P', - - range: [12, 13], - loc: { - start: { column: 12, line: 1 }, - end: { column: 13, line: 1 }, - }, - }, - Keyword { - type: 'Keyword', - value: 'in', - - range: [14, 16], - loc: { - start: { column: 14, line: 1 }, - end: { column: 16, line: 1 }, - }, - }, - Identifier { - type: 'Identifier', - value: 'string', - - range: [17, 23], - loc: { - start: { column: 17, line: 1 }, - end: { column: 23, line: 1 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ']', - - range: [23, 24], - loc: { - start: { column: 23, line: 1 }, - end: { column: 24, line: 1 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ':', - - range: [24, 25], - loc: { - start: { column: 24, line: 1 }, - end: { column: 25, line: 1 }, - }, - }, - Identifier { - type: 'Identifier', - value: 'number', - - range: [26, 32], - loc: { - start: { column: 26, line: 1 }, - end: { column: 32, line: 1 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: '}', - - range: [33, 34], - loc: { - start: { column: 33, line: 1 }, - end: { column: 34, line: 1 }, - }, - }, - Punctuator { - type: 'Punctuator', - value: ';', - - range: [34, 35], - loc: { - start: { column: 34, line: 1 }, - end: { column: 35, line: 1 }, - }, - }, - ] diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/fixture.ts new file mode 100644 index 000000000000..4296694ae99a --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/fixture.ts @@ -0,0 +1,3 @@ +type T = { + [K in any]?: any; +}; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..ec3bc8ac20f9 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,75 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "T", + optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "K", + optional: false, + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + nameType: null, + optional: true, + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [26, 29], + loc: { + start: { column: 15, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + + range: [9, 32], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/2-TSESTree-Tokens.shot similarity index 51% rename from packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/2-TSESTree-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/2-TSESTree-Tokens.shot index 85461341dfcc..1ca17e133643 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/2-TSESTree-Tokens.shot @@ -1,27 +1,27 @@ [ - Keyword { - type: "Keyword", - value: "let", + Identifier { + type: "Identifier", + value: "type", - range: [0, 3], + range: [0, 4], loc: { start: { column: 0, line: 1 }, - end: { column: 3, line: 1 }, + end: { column: 4, line: 1 }, }, }, Identifier { type: "Identifier", - value: "map", + value: "T", - range: [4, 7], + range: [5, 6], loc: { - start: { column: 4, line: 1 }, - end: { column: 7, line: 1 }, + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, }, }, Punctuator { type: "Punctuator", - value: ":", + value: "=", range: [7, 8], loc: { @@ -43,50 +43,60 @@ type: "Punctuator", value: "[", - range: [11, 12], + range: [13, 14], loc: { - start: { column: 11, line: 1 }, - end: { column: 12, line: 1 }, + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, }, }, Identifier { type: "Identifier", - value: "P", + value: "K", - range: [12, 13], + range: [14, 15], loc: { - start: { column: 12, line: 1 }, - end: { column: 13, line: 1 }, + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, }, }, Keyword { type: "Keyword", value: "in", - range: [14, 16], + range: [16, 18], loc: { - start: { column: 14, line: 1 }, - end: { column: 16, line: 1 }, + start: { column: 5, line: 2 }, + end: { column: 7, line: 2 }, }, }, Identifier { type: "Identifier", - value: "string", + value: "any", - range: [17, 23], + range: [19, 22], loc: { - start: { column: 17, line: 1 }, - end: { column: 23, line: 1 }, + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, }, }, Punctuator { type: "Punctuator", value: "]", + range: [22, 23], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + range: [23, 24], loc: { - start: { column: 23, line: 1 }, - end: { column: 24, line: 1 }, + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, }, }, Punctuator { @@ -95,38 +105,48 @@ range: [24, 25], loc: { - start: { column: 24, line: 1 }, - end: { column: 25, line: 1 }, + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, }, }, Identifier { type: "Identifier", - value: "number", + value: "any", + + range: [26, 29], + loc: { + start: { column: 15, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", - range: [26, 32], + range: [29, 30], loc: { - start: { column: 26, line: 1 }, - end: { column: 32, line: 1 }, + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, }, }, Punctuator { type: "Punctuator", value: "}", - range: [33, 34], + range: [31, 32], loc: { - start: { column: 33, line: 1 }, - end: { column: 34, line: 1 }, + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [34, 35], + range: [32, 33], loc: { - start: { column: 34, line: 1 }, - end: { column: 35, line: 1 }, + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, }, }, ] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..951124f0703f --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/3-Babel-AST.shot @@ -0,0 +1,70 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + optional: true, + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [26, 29], + loc: { + start: { column: 15, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + name: "K", + + range: [14, 22], + loc: { + start: { column: 3, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + + range: [9, 32], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/4-Babel-Tokens.shot similarity index 53% rename from packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/4-Babel-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/4-Babel-Tokens.shot index 1ee42402051d..1ca17e133643 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/base/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/4-Babel-Tokens.shot @@ -1,27 +1,27 @@ [ Identifier { type: "Identifier", - value: "let", + value: "type", - range: [0, 3], + range: [0, 4], loc: { start: { column: 0, line: 1 }, - end: { column: 3, line: 1 }, + end: { column: 4, line: 1 }, }, }, Identifier { type: "Identifier", - value: "map", + value: "T", - range: [4, 7], + range: [5, 6], loc: { - start: { column: 4, line: 1 }, - end: { column: 7, line: 1 }, + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, }, }, Punctuator { type: "Punctuator", - value: ":", + value: "=", range: [7, 8], loc: { @@ -43,50 +43,60 @@ type: "Punctuator", value: "[", - range: [11, 12], + range: [13, 14], loc: { - start: { column: 11, line: 1 }, - end: { column: 12, line: 1 }, + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, }, }, Identifier { type: "Identifier", - value: "P", + value: "K", - range: [12, 13], + range: [14, 15], loc: { - start: { column: 12, line: 1 }, - end: { column: 13, line: 1 }, + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, }, }, Keyword { type: "Keyword", value: "in", - range: [14, 16], + range: [16, 18], loc: { - start: { column: 14, line: 1 }, - end: { column: 16, line: 1 }, + start: { column: 5, line: 2 }, + end: { column: 7, line: 2 }, }, }, Identifier { type: "Identifier", - value: "string", + value: "any", - range: [17, 23], + range: [19, 22], loc: { - start: { column: 17, line: 1 }, - end: { column: 23, line: 1 }, + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, }, }, Punctuator { type: "Punctuator", value: "]", + range: [22, 23], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + range: [23, 24], loc: { - start: { column: 23, line: 1 }, - end: { column: 24, line: 1 }, + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, }, }, Punctuator { @@ -95,38 +105,48 @@ range: [24, 25], loc: { - start: { column: 24, line: 1 }, - end: { column: 25, line: 1 }, + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, }, }, Identifier { type: "Identifier", - value: "number", + value: "any", + + range: [26, 29], + loc: { + start: { column: 15, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", - range: [26, 32], + range: [29, 30], loc: { - start: { column: 26, line: 1 }, - end: { column: 32, line: 1 }, + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, }, }, Punctuator { type: "Punctuator", value: "}", - range: [33, 34], + range: [31, 32], loc: { - start: { column: 33, line: 1 }, - end: { column: 34, line: 1 }, + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [34, 35], + range: [32, 33], loc: { - start: { column: 34, line: 1 }, - end: { column: 35, line: 1 }, + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, }, }, ] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..0592c78df5b9 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,101 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > optional-minus > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'T', +- optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSAnyKeyword { +- type: 'TSAnyKeyword', +- +- range: [19, 22], +- loc: { +- start: { column: 8, line: 2 }, +- end: { column: 11, line: 2 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'K', +- optional: false, +- +- range: [14, 15], +- loc: { +- start: { column: 3, line: 2 }, +- end: { column: 4, line: 2 }, +- }, +- }, + nameType: null, + optional: true, + typeAnnotation: TSAnyKeyword { + type: 'TSAnyKeyword', + + range: [26, 29], + loc: { + start: { column: 15, line: 2 }, + end: { column: 18, line: 2 }, ++ }, ++ }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSAnyKeyword { ++ type: 'TSAnyKeyword', ++ ++ range: [19, 22], ++ loc: { ++ start: { column: 8, line: 2 }, ++ end: { column: 11, line: 2 }, ++ }, ++ }, ++ name: 'K', ++ ++ range: [14, 22], ++ loc: { ++ start: { column: 3, line: 2 }, ++ end: { column: 11, line: 2 }, + }, + }, + + range: [9, 32], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..e1adf4d8ccec --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,5 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > optional-minus > AST Alignment - Token`] +Snapshot Diff: +Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/fixture.ts new file mode 100644 index 000000000000..3ba522247e25 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/fixture.ts @@ -0,0 +1,3 @@ +type T = { + [K in any]+?: any; +}; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..7ab20722ff01 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,75 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "T", + optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "K", + optional: false, + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + nameType: null, + optional: "+", + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [27, 30], + loc: { + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + + range: [9, 33], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..4e4960266005 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,162 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "K", + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [16, 18], + loc: { + start: { column: 5, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [22, 23], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "+", + + range: [23, 24], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [24, 25], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [25, 26], + loc: { + start: { column: 14, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [27, 30], + loc: { + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [30, 31], + loc: { + start: { column: 19, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [32, 33], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [33, 34], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..a53f741d7671 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/3-Babel-AST.shot @@ -0,0 +1,70 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + optional: "+", + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [27, 30], + loc: { + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + name: "K", + + range: [14, 22], + loc: { + start: { column: 3, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + + range: [9, 33], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..4e4960266005 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,162 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "K", + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [16, 18], + loc: { + start: { column: 5, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [22, 23], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "+", + + range: [23, 24], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [24, 25], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [25, 26], + loc: { + start: { column: 14, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [27, 30], + loc: { + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [30, 31], + loc: { + start: { column: 19, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [32, 33], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [33, 34], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..0af20518c5ac --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,101 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > optional-plus > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'T', +- optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSAnyKeyword { +- type: 'TSAnyKeyword', +- +- range: [19, 22], +- loc: { +- start: { column: 8, line: 2 }, +- end: { column: 11, line: 2 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'K', +- optional: false, +- +- range: [14, 15], +- loc: { +- start: { column: 3, line: 2 }, +- end: { column: 4, line: 2 }, +- }, +- }, + nameType: null, + optional: '+', + typeAnnotation: TSAnyKeyword { + type: 'TSAnyKeyword', + + range: [27, 30], + loc: { + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, ++ }, ++ }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSAnyKeyword { ++ type: 'TSAnyKeyword', ++ ++ range: [19, 22], ++ loc: { ++ start: { column: 8, line: 2 }, ++ end: { column: 11, line: 2 }, ++ }, ++ }, ++ name: 'K', ++ ++ range: [14, 22], ++ loc: { ++ start: { column: 3, line: 2 }, ++ end: { column: 11, line: 2 }, + }, + }, + + range: [9, 33], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..cf0536defdec --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-plus/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,5 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > optional-plus > AST Alignment - Token`] +Snapshot Diff: +Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/fixture.ts new file mode 100644 index 000000000000..f759cd13200d --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/fixture.ts @@ -0,0 +1,3 @@ +type T = { + [K in any]-?: any; +}; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..ed550983f9fd --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,75 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "T", + optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "K", + optional: false, + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + nameType: null, + optional: "-", + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [27, 30], + loc: { + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + + range: [9, 33], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..2d2ad113c249 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,162 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "K", + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [16, 18], + loc: { + start: { column: 5, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [22, 23], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "-", + + range: [23, 24], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [24, 25], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [25, 26], + loc: { + start: { column: 14, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [27, 30], + loc: { + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [30, 31], + loc: { + start: { column: 19, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [32, 33], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [33, 34], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..089aec05bc1a --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/3-Babel-AST.shot @@ -0,0 +1,70 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + optional: "-", + typeAnnotation: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [27, 30], + loc: { + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSAnyKeyword { + type: "TSAnyKeyword", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + name: "K", + + range: [14, 22], + loc: { + start: { column: 3, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + + range: [9, 33], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..2d2ad113c249 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,162 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + 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 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "K", + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [16, 18], + loc: { + start: { column: 5, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [19, 22], + loc: { + start: { column: 8, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [22, 23], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "-", + + range: [23, 24], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [24, 25], + loc: { + start: { column: 13, line: 2 }, + end: { column: 14, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [25, 26], + loc: { + start: { column: 14, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "any", + + range: [27, 30], + loc: { + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [30, 31], + loc: { + start: { column: 19, line: 2 }, + end: { column: 20, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [32, 33], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [33, 34], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..22fe4722f117 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,101 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > optional > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'T', +- optional: false, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSAnyKeyword { +- type: 'TSAnyKeyword', +- +- range: [19, 22], +- loc: { +- start: { column: 8, line: 2 }, +- end: { column: 11, line: 2 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'K', +- optional: false, +- +- range: [14, 15], +- loc: { +- start: { column: 3, line: 2 }, +- end: { column: 4, line: 2 }, +- }, +- }, + nameType: null, + optional: '-', + typeAnnotation: TSAnyKeyword { + type: 'TSAnyKeyword', + + range: [27, 30], + loc: { + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, ++ }, ++ }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSAnyKeyword { ++ type: 'TSAnyKeyword', ++ ++ range: [19, 22], ++ loc: { ++ start: { column: 8, line: 2 }, ++ end: { column: 11, line: 2 }, ++ }, ++ }, ++ name: 'K', ++ ++ range: [14, 22], ++ loc: { ++ start: { column: 3, line: 2 }, ++ end: { column: 11, line: 2 }, + }, + }, + + range: [9, 33], + loc: { + start: { column: 9, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 35], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..91ebb5abdd6d --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,5 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > optional > AST Alignment - Token`] +Snapshot Diff: +Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/fixture.ts similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/fixture.ts rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/fixture.ts diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/1-TSESTree-AST.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/1-TSESTree-AST.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/1-TSESTree-AST.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/2-TSESTree-Tokens.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/2-TSESTree-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/2-TSESTree-Tokens.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/3-Babel-AST.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/3-Babel-AST.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/3-Babel-AST.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/4-Babel-Tokens.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/4-Babel-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/4-Babel-Tokens.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/5-AST-Alignment-AST.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/5-AST-Alignment-AST.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/5-AST-Alignment-AST.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/6-AST-Alignment-Tokens.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-minus/snapshots/6-AST-Alignment-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/6-AST-Alignment-Tokens.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/fixture.ts similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/fixture.ts rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/fixture.ts diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/1-TSESTree-AST.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/1-TSESTree-AST.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/1-TSESTree-AST.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/2-TSESTree-Tokens.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/2-TSESTree-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/2-TSESTree-Tokens.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/3-Babel-AST.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/3-Babel-AST.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/3-Babel-AST.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/4-Babel-Tokens.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/4-Babel-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/4-Babel-Tokens.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/5-AST-Alignment-AST.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/5-AST-Alignment-AST.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/5-AST-Alignment-AST.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/6-AST-Alignment-Tokens.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly-plus/snapshots/6-AST-Alignment-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/6-AST-Alignment-Tokens.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/fixture.ts similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/fixture.ts rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly/fixture.ts diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/1-TSESTree-AST.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/1-TSESTree-AST.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/1-TSESTree-AST.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/2-TSESTree-Tokens.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/2-TSESTree-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/2-TSESTree-Tokens.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/3-Babel-AST.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/3-Babel-AST.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/3-Babel-AST.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/4-Babel-Tokens.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/4-Babel-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/4-Babel-Tokens.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/5-AST-Alignment-AST.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/5-AST-Alignment-AST.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/5-AST-Alignment-AST.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/6-AST-Alignment-Tokens.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/with-modifiers-readonly/snapshots/6-AST-Alignment-Tokens.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/6-AST-Alignment-Tokens.shot diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot index 279bf442416a..adc389200098 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-ast.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot @@ -525,8 +525,10 @@ exports[`AST Fixtures > List fixtures with AST differences`] "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/TSMappedType/fixtures/base/fixture.ts", "type/TSMappedType/fixtures/no-modifiers/fixture.ts", + "type/TSMappedType/fixtures/optional-minus/fixture.ts", + "type/TSMappedType/fixtures/optional-plus/fixture.ts", + "type/TSMappedType/fixtures/optional/fixture.ts", "type/TSMappedType/fixtures/with-modifiers-readonly-minus/fixture.ts", "type/TSMappedType/fixtures/with-modifiers-readonly-plus/fixture.ts", "type/TSMappedType/fixtures/with-modifiers-readonly/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 0e59d2ed8cda..3a3acb3c5aef 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot @@ -134,6 +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/TSMappedType/fixtures/base/fixture.ts" + "type/TSImportType/fixtures/type-import-type-with-import-attributes/fixture.ts" ] From a49f80235b174c65e95d33a01150d31eb3803933 Mon Sep 17 00:00:00 2001 From: bradzacher Date: Mon, 5 May 2025 12:18:37 +0930 Subject: [PATCH 10/12] add fixture for readonly optional --- .../fixtures/readonly-optional/fixture.ts | 3 + .../snapshots/1-TSESTree-AST.shot | 76 ++++++++ .../snapshots/2-TSESTree-Tokens.shot | 162 ++++++++++++++++++ .../snapshots/3-Babel-AST.shot | 71 ++++++++ .../snapshots/4-Babel-Tokens.shot | 162 ++++++++++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 102 +++++++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 5 + 7 files changed, 581 insertions(+) create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/fixture.ts create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/6-AST-Alignment-Tokens.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/fixture.ts new file mode 100644 index 000000000000..3d965c3064c2 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/fixture.ts @@ -0,0 +1,3 @@ +type ReadonlyOptional = { + readonly [P in string]: number; +}; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..ce3b5b1785e9 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,76 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: false, + id: Identifier { + type: "Identifier", + decorators: [], + name: "ReadonlyOptional", + optional: false, + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + nameType: null, + optional: true, + readonly: true, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + + range: [24, 62], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 63], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 64], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..1dc2635c20ca --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,162 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [28, 36], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [37, 38], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [40, 42], + loc: { + start: { column: 14, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [49, 50], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [50, 51], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [51, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [59, 60], + loc: { + start: { column: 33, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [61, 62], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [62, 63], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..dcba1b68e86f --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/3-Babel-AST.shot @@ -0,0 +1,71 @@ +Program { + type: "Program", + body: [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: "TSMappedType", + nameType: null, + optional: true, + readonly: true, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { + type: "TSTypeParameter", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + name: "P", + + range: [38, 49], + loc: { + start: { column: 12, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + + range: [24, 62], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 63], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 64], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..1dc2635c20ca --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,162 @@ +[ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "ReadonlyOptional", + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "readonly", + + range: [28, 36], + loc: { + start: { column: 2, line: 2 }, + end: { column: 10, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [37, 38], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "P", + + range: [38, 39], + loc: { + start: { column: 12, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "in", + + range: [40, 42], + loc: { + start: { column: 14, line: 2 }, + end: { column: 16, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [43, 49], + loc: { + start: { column: 17, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [49, 50], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [50, 51], + loc: { + start: { column: 24, line: 2 }, + end: { column: 25, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [51, 52], + loc: { + start: { column: 25, line: 2 }, + end: { column: 26, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [59, 60], + loc: { + start: { column: 33, line: 2 }, + end: { column: 34, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [61, 62], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [62, 63], + loc: { + start: { column: 1, line: 3 }, + end: { column: 2, line: 3 }, + }, + }, +] \ No newline at end of file diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..68c7e8a9ff0f --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,102 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly > AST Alignment - AST`] +Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', +- declare: false, + id: Identifier { + type: 'Identifier', +- decorators: Array [], + name: 'ReadonlyOptional', +- optional: false, + + range: [5, 21], + loc: { + start: { column: 5, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + typeAnnotation: TSMappedType { + type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [43, 49], +- loc: { +- start: { column: 17, line: 2 }, +- end: { column: 23, line: 2 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [38, 39], +- loc: { +- start: { column: 12, line: 2 }, +- end: { column: 13, line: 2 }, +- }, +- }, + nameType: null, + optional: true, + readonly: true, + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [53, 59], + loc: { + start: { column: 27, line: 2 }, + end: { column: 33, line: 2 }, ++ }, ++ }, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', ++ ++ range: [43, 49], ++ loc: { ++ start: { column: 17, line: 2 }, ++ end: { column: 23, line: 2 }, ++ }, ++ }, ++ name: 'P', ++ ++ range: [38, 49], ++ loc: { ++ start: { column: 12, line: 2 }, ++ end: { column: 23, line: 2 }, + }, + }, + + range: [24, 62], + loc: { + start: { column: 24, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + + range: [0, 63], + loc: { + start: { column: 0, line: 1 }, + end: { column: 2, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 64], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + } diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..2bd890ccf742 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,5 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly > AST Alignment - Token`] +Snapshot Diff: +Compared values have no visual difference. From 6bb0a66a3a8179daade1fe22ccec07f28db184f9 Mon Sep 17 00:00:00 2001 From: bradzacher Date: Mon, 5 May 2025 12:19:21 +0930 Subject: [PATCH 11/12] oops fix fixtures --- .../src/type/TSMappedType/fixtures/optional-minus/fixture.ts | 2 +- .../ast-spec/src/type/TSMappedType/fixtures/optional/fixture.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/fixture.ts index 4296694ae99a..f759cd13200d 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/fixture.ts +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/fixture.ts @@ -1,3 +1,3 @@ type T = { - [K in any]?: any; + [K in any]-?: any; }; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/fixture.ts index f759cd13200d..4296694ae99a 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/fixture.ts +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/fixture.ts @@ -1,3 +1,3 @@ type T = { - [K in any]-?: any; + [K in any]?: any; }; From 656a3f96b4ccf7e3d4e646aa69b48f85a3cb41d9 Mon Sep 17 00:00:00 2001 From: bradzacher Date: Mon, 5 May 2025 12:20:47 +0930 Subject: [PATCH 12/12] fix fixtures --- .../snapshots/3-Alignment-Error.shot | 4 --- .../fixture.ts | 0 .../snapshots/1-Babel-Error.shot | 0 .../snapshots/1-TSESTree-Error.shot | 2 +- .../snapshots/2-Alignment-Error.shot | 0 .../snapshots/2-Babel-Error.shot | 2 +- .../snapshots/3-Alignment-Error.shot | 2 +- .../fixture.ts | 0 .../snapshots/1-Babel-Error.shot | 0 .../snapshots/1-TSESTree-Error.shot | 2 +- .../snapshots/2-Alignment-Error.shot | 0 .../snapshots/2-Babel-Error.shot | 2 +- .../snapshots/3-Alignment-Error.shot | 4 +++ .../snapshots/1-TSESTree-AST.shot | 14 ++++----- .../snapshots/2-TSESTree-Tokens.shot | 30 ++++++++++++------- .../optional-minus/snapshots/3-Babel-AST.shot | 14 ++++----- .../snapshots/4-Babel-Tokens.shot | 30 ++++++++++++------- .../snapshots/5-AST-Alignment-AST.shot | 14 ++++----- .../optional/snapshots/1-TSESTree-AST.shot | 14 ++++----- .../optional/snapshots/2-TSESTree-Tokens.shot | 30 +++++++------------ .../optional/snapshots/3-Babel-AST.shot | 14 ++++----- .../optional/snapshots/4-Babel-Tokens.shot | 30 +++++++------------ .../snapshots/5-AST-Alignment-AST.shot | 14 ++++----- .../snapshots/5-AST-Alignment-AST.shot | 2 +- .../snapshots/6-AST-Alignment-Tokens.shot | 2 +- .../snapshots/1-TSESTree-AST.shot | 14 ++++----- .../snapshots/2-TSESTree-Tokens.shot | 28 ++++++----------- .../snapshots/3-Babel-AST.shot | 13 ++++---- .../snapshots/4-Babel-Tokens.shot | 28 ++++++----------- .../snapshots/5-AST-Alignment-AST.shot | 16 +++++----- .../snapshots/6-AST-Alignment-Tokens.shot | 2 +- .../snapshots/5-AST-Alignment-AST.shot | 2 +- .../snapshots/6-AST-Alignment-Tokens.shot | 2 +- .../snapshots/5-AST-Alignment-AST.shot | 2 +- .../snapshots/6-AST-Alignment-Tokens.shot | 2 +- .../tests/fixtures-with-differences-ast.shot | 7 +++-- 36 files changed, 161 insertions(+), 181 deletions(-) delete mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/3-Alignment-Error.shot rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{with-member => with-member-after}/fixture.ts (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{with-member => with-member-after}/snapshots/1-Babel-Error.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{with-member => with-member-after}/snapshots/1-TSESTree-Error.shot (90%) rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{with-member => with-member-after}/snapshots/2-Alignment-Error.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{with-member => with-member-after}/snapshots/2-Babel-Error.shot (86%) rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{with-member => with-member-after}/snapshots/3-Alignment-Error.shot (82%) rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{looks-like-mapped-type-but-with-members => with-member-before}/fixture.ts (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{looks-like-mapped-type-but-with-members => with-member-before}/snapshots/1-Babel-Error.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{looks-like-mapped-type-but-with-members => with-member-before}/snapshots/1-TSESTree-Error.shot (63%) rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{looks-like-mapped-type-but-with-members => with-member-before}/snapshots/2-Alignment-Error.shot (100%) rename packages/ast-spec/src/type/TSMappedType/fixtures/_error_/{looks-like-mapped-type-but-with-members => with-member-before}/snapshots/2-Babel-Error.shot (50%) create mode 100644 packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/3-Alignment-Error.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/3-Alignment-Error.shot deleted file mode 100644 index f437a6d2c415..000000000000 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/3-Alignment-Error.shot +++ /dev/null @@ -1,4 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`AST Fixtures > type > TSMappedType > _error_ > looks-like-mapped-type-but-with-members > Error Alignment`] -Both errored diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/fixture.ts similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/fixture.ts rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/fixture.ts diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/1-Babel-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/1-Babel-Error.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/1-Babel-Error.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/1-Babel-Error.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/1-TSESTree-Error.shot similarity index 90% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/1-TSESTree-Error.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/1-TSESTree-Error.shot index 744e922376a2..de0bae168fda 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/1-TSESTree-Error.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/1-TSESTree-Error.shot @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > _error_ > with-member > TSESTree - Error`] +exports[`AST Fixtures > type > TSMappedType > _error_ > with-member-after > TSESTree - Error`] TSError 1 | type Mapped = { 2 | [key in keyof O]: number; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/2-Alignment-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/2-Alignment-Error.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/2-Alignment-Error.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/2-Alignment-Error.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/2-Babel-Error.shot similarity index 86% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/2-Babel-Error.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/2-Babel-Error.shot index 02ac78f26e15..9f5f417fcabd 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/2-Babel-Error.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/2-Babel-Error.shot @@ -1,4 +1,4 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > _error_ > with-member > Babel - Error`] +exports[`AST Fixtures > type > TSMappedType > _error_ > with-member-after > Babel - Error`] SyntaxError: Unexpected token, expected "}" (3:2) diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/3-Alignment-Error.shot similarity index 82% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/3-Alignment-Error.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/3-Alignment-Error.shot index 356781d94e3d..bdbc90c17cb0 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member/snapshots/3-Alignment-Error.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-after/snapshots/3-Alignment-Error.shot @@ -1,4 +1,4 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > _error_ > with-member > Error Alignment`] +exports[`AST Fixtures > type > TSMappedType > _error_ > with-member-after > Error Alignment`] Both errored diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/fixture.ts b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/fixture.ts similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/fixture.ts rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/fixture.ts diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/1-Babel-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/1-Babel-Error.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/1-Babel-Error.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/1-Babel-Error.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/1-TSESTree-Error.shot similarity index 63% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/1-TSESTree-Error.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/1-TSESTree-Error.shot index 2c4ca093ca0a..34483c684ca8 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/1-TSESTree-Error.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/1-TSESTree-Error.shot @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > _error_ > looks-like-mapped-type-but-with-members > TSESTree - Error`] +exports[`AST Fixtures > type > TSMappedType > _error_ > with-member-before > TSESTree - Error`] TSError 1 | type Mapped = { 2 | member: member; diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/2-Alignment-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/2-Alignment-Error.shot similarity index 100% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/2-Alignment-Error.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/2-Alignment-Error.shot diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/2-Babel-Error.shot similarity index 50% rename from packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/2-Babel-Error.shot rename to packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/2-Babel-Error.shot index bba41049c6c1..c1f120be3d57 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/looks-like-mapped-type-but-with-members/snapshots/2-Babel-Error.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/2-Babel-Error.shot @@ -1,4 +1,4 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > _error_ > looks-like-mapped-type-but-with-members > Babel - Error`] +exports[`AST Fixtures > type > TSMappedType > _error_ > with-member-before > Babel - Error`] SyntaxError: Unexpected token, expected "]" (3:16) diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..117552d9c320 --- /dev/null +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/_error_/with-member-before/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > type > TSMappedType > _error_ > with-member-before > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/1-TSESTree-AST.shot index ec3bc8ac20f9..ed550983f9fd 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/1-TSESTree-AST.shot @@ -40,25 +40,25 @@ Program { }, }, nameType: null, - optional: true, + optional: "-", typeAnnotation: TSAnyKeyword { type: "TSAnyKeyword", - range: [26, 29], + range: [27, 30], loc: { - start: { column: 15, line: 2 }, - end: { column: 18, line: 2 }, + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, }, }, - range: [9, 32], + range: [9, 33], loc: { start: { column: 9, line: 1 }, end: { column: 1, line: 3 }, }, }, - range: [0, 33], + range: [0, 34], loc: { start: { column: 0, line: 1 }, end: { column: 2, line: 3 }, @@ -67,7 +67,7 @@ Program { ], sourceType: "script", - range: [0, 34], + range: [0, 35], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 4 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/2-TSESTree-Tokens.shot index 1ca17e133643..2d2ad113c249 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/2-TSESTree-Tokens.shot @@ -91,7 +91,7 @@ }, Punctuator { type: "Punctuator", - value: "?", + value: "-", range: [23, 24], loc: { @@ -101,7 +101,7 @@ }, Punctuator { type: "Punctuator", - value: ":", + value: "?", range: [24, 25], loc: { @@ -109,31 +109,41 @@ end: { column: 14, line: 2 }, }, }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [25, 26], + loc: { + start: { column: 14, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, Identifier { type: "Identifier", value: "any", - range: [26, 29], + range: [27, 30], loc: { - start: { column: 15, line: 2 }, - end: { column: 18, line: 2 }, + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [29, 30], + range: [30, 31], loc: { - start: { column: 18, line: 2 }, - end: { column: 19, line: 2 }, + start: { column: 19, line: 2 }, + end: { column: 20, line: 2 }, }, }, Punctuator { type: "Punctuator", value: "}", - range: [31, 32], + range: [32, 33], loc: { start: { column: 0, line: 3 }, end: { column: 1, line: 3 }, @@ -143,7 +153,7 @@ type: "Punctuator", value: ";", - range: [32, 33], + range: [33, 34], loc: { start: { column: 1, line: 3 }, end: { column: 2, line: 3 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/3-Babel-AST.shot index 951124f0703f..089aec05bc1a 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/3-Babel-AST.shot @@ -16,14 +16,14 @@ Program { typeAnnotation: TSMappedType { type: "TSMappedType", nameType: null, - optional: true, + optional: "-", typeAnnotation: TSAnyKeyword { type: "TSAnyKeyword", - range: [26, 29], + range: [27, 30], loc: { - start: { column: 15, line: 2 }, - end: { column: 18, line: 2 }, + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, }, }, typeParameter: TSTypeParameter { @@ -46,14 +46,14 @@ Program { }, }, - range: [9, 32], + range: [9, 33], loc: { start: { column: 9, line: 1 }, end: { column: 1, line: 3 }, }, }, - range: [0, 33], + range: [0, 34], loc: { start: { column: 0, line: 1 }, end: { column: 2, line: 3 }, @@ -62,7 +62,7 @@ Program { ], sourceType: "script", - range: [0, 34], + range: [0, 35], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 4 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/4-Babel-Tokens.shot index 1ca17e133643..2d2ad113c249 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/4-Babel-Tokens.shot @@ -91,7 +91,7 @@ }, Punctuator { type: "Punctuator", - value: "?", + value: "-", range: [23, 24], loc: { @@ -101,7 +101,7 @@ }, Punctuator { type: "Punctuator", - value: ":", + value: "?", range: [24, 25], loc: { @@ -109,31 +109,41 @@ end: { column: 14, line: 2 }, }, }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [25, 26], + loc: { + start: { column: 14, line: 2 }, + end: { column: 15, line: 2 }, + }, + }, Identifier { type: "Identifier", value: "any", - range: [26, 29], + range: [27, 30], loc: { - start: { column: 15, line: 2 }, - end: { column: 18, line: 2 }, + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [29, 30], + range: [30, 31], loc: { - start: { column: 18, line: 2 }, - end: { column: 19, line: 2 }, + start: { column: 19, line: 2 }, + end: { column: 20, line: 2 }, }, }, Punctuator { type: "Punctuator", value: "}", - range: [31, 32], + range: [32, 33], loc: { start: { column: 0, line: 3 }, end: { column: 1, line: 3 }, @@ -143,7 +153,7 @@ type: "Punctuator", value: ";", - range: [32, 33], + range: [33, 34], loc: { start: { column: 1, line: 3 }, end: { column: 2, line: 3 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/5-AST-Alignment-AST.shot index 0592c78df5b9..866a68796a21 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional-minus/snapshots/5-AST-Alignment-AST.shot @@ -47,14 +47,14 @@ Snapshot Diff: - }, - }, nameType: null, - optional: true, + optional: '-', typeAnnotation: TSAnyKeyword { type: 'TSAnyKeyword', - range: [26, 29], + range: [27, 30], loc: { - start: { column: 15, line: 2 }, - end: { column: 18, line: 2 }, + start: { column: 16, line: 2 }, + end: { column: 19, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { @@ -77,14 +77,14 @@ Snapshot Diff: }, }, - range: [9, 32], + range: [9, 33], loc: { start: { column: 9, line: 1 }, end: { column: 1, line: 3 }, }, }, - range: [0, 33], + range: [0, 34], loc: { start: { column: 0, line: 1 }, end: { column: 2, line: 3 }, @@ -93,7 +93,7 @@ Snapshot Diff: ], sourceType: 'script', - range: [0, 34], + range: [0, 35], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 4 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/1-TSESTree-AST.shot index ed550983f9fd..ec3bc8ac20f9 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/1-TSESTree-AST.shot @@ -40,25 +40,25 @@ Program { }, }, nameType: null, - optional: "-", + optional: true, typeAnnotation: TSAnyKeyword { type: "TSAnyKeyword", - range: [27, 30], + range: [26, 29], loc: { - start: { column: 16, line: 2 }, - end: { column: 19, line: 2 }, + start: { column: 15, line: 2 }, + end: { column: 18, line: 2 }, }, }, - range: [9, 33], + range: [9, 32], loc: { start: { column: 9, line: 1 }, end: { column: 1, line: 3 }, }, }, - range: [0, 34], + range: [0, 33], loc: { start: { column: 0, line: 1 }, end: { column: 2, line: 3 }, @@ -67,7 +67,7 @@ Program { ], sourceType: "script", - range: [0, 35], + range: [0, 34], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 4 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/2-TSESTree-Tokens.shot index 2d2ad113c249..1ca17e133643 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/2-TSESTree-Tokens.shot @@ -91,7 +91,7 @@ }, Punctuator { type: "Punctuator", - value: "-", + value: "?", range: [23, 24], loc: { @@ -101,7 +101,7 @@ }, Punctuator { type: "Punctuator", - value: "?", + value: ":", range: [24, 25], loc: { @@ -109,41 +109,31 @@ end: { column: 14, line: 2 }, }, }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [25, 26], - loc: { - start: { column: 14, line: 2 }, - end: { column: 15, line: 2 }, - }, - }, Identifier { type: "Identifier", value: "any", - range: [27, 30], + range: [26, 29], loc: { - start: { column: 16, line: 2 }, - end: { column: 19, line: 2 }, + start: { column: 15, line: 2 }, + end: { column: 18, line: 2 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [30, 31], + range: [29, 30], loc: { - start: { column: 19, line: 2 }, - end: { column: 20, line: 2 }, + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, }, }, Punctuator { type: "Punctuator", value: "}", - range: [32, 33], + range: [31, 32], loc: { start: { column: 0, line: 3 }, end: { column: 1, line: 3 }, @@ -153,7 +143,7 @@ type: "Punctuator", value: ";", - range: [33, 34], + range: [32, 33], loc: { start: { column: 1, line: 3 }, end: { column: 2, line: 3 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/3-Babel-AST.shot index 089aec05bc1a..951124f0703f 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/3-Babel-AST.shot @@ -16,14 +16,14 @@ Program { typeAnnotation: TSMappedType { type: "TSMappedType", nameType: null, - optional: "-", + optional: true, typeAnnotation: TSAnyKeyword { type: "TSAnyKeyword", - range: [27, 30], + range: [26, 29], loc: { - start: { column: 16, line: 2 }, - end: { column: 19, line: 2 }, + start: { column: 15, line: 2 }, + end: { column: 18, line: 2 }, }, }, typeParameter: TSTypeParameter { @@ -46,14 +46,14 @@ Program { }, }, - range: [9, 33], + range: [9, 32], loc: { start: { column: 9, line: 1 }, end: { column: 1, line: 3 }, }, }, - range: [0, 34], + range: [0, 33], loc: { start: { column: 0, line: 1 }, end: { column: 2, line: 3 }, @@ -62,7 +62,7 @@ Program { ], sourceType: "script", - range: [0, 35], + range: [0, 34], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 4 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/4-Babel-Tokens.shot index 2d2ad113c249..1ca17e133643 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/4-Babel-Tokens.shot @@ -91,7 +91,7 @@ }, Punctuator { type: "Punctuator", - value: "-", + value: "?", range: [23, 24], loc: { @@ -101,7 +101,7 @@ }, Punctuator { type: "Punctuator", - value: "?", + value: ":", range: [24, 25], loc: { @@ -109,41 +109,31 @@ end: { column: 14, line: 2 }, }, }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [25, 26], - loc: { - start: { column: 14, line: 2 }, - end: { column: 15, line: 2 }, - }, - }, Identifier { type: "Identifier", value: "any", - range: [27, 30], + range: [26, 29], loc: { - start: { column: 16, line: 2 }, - end: { column: 19, line: 2 }, + start: { column: 15, line: 2 }, + end: { column: 18, line: 2 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [30, 31], + range: [29, 30], loc: { - start: { column: 19, line: 2 }, - end: { column: 20, line: 2 }, + start: { column: 18, line: 2 }, + end: { column: 19, line: 2 }, }, }, Punctuator { type: "Punctuator", value: "}", - range: [32, 33], + range: [31, 32], loc: { start: { column: 0, line: 3 }, end: { column: 1, line: 3 }, @@ -153,7 +143,7 @@ type: "Punctuator", value: ";", - range: [33, 34], + range: [32, 33], loc: { start: { column: 1, line: 3 }, end: { column: 2, line: 3 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/5-AST-Alignment-AST.shot index 22fe4722f117..4ce829da2429 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/optional/snapshots/5-AST-Alignment-AST.shot @@ -47,14 +47,14 @@ Snapshot Diff: - }, - }, nameType: null, - optional: '-', + optional: true, typeAnnotation: TSAnyKeyword { type: 'TSAnyKeyword', - range: [27, 30], + range: [26, 29], loc: { - start: { column: 16, line: 2 }, - end: { column: 19, line: 2 }, + start: { column: 15, line: 2 }, + end: { column: 18, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { @@ -77,14 +77,14 @@ Snapshot Diff: }, }, - range: [9, 33], + range: [9, 32], loc: { start: { column: 9, line: 1 }, end: { column: 1, line: 3 }, }, }, - range: [0, 34], + range: [0, 33], loc: { start: { column: 0, line: 1 }, end: { column: 2, line: 3 }, @@ -93,7 +93,7 @@ Snapshot Diff: ], sourceType: 'script', - range: [0, 35], + range: [0, 34], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 4 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/5-AST-Alignment-AST.shot index 77f6e5412683..00517798d7d1 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/5-AST-Alignment-AST.shot @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly-minus > AST Alignment - AST`] +exports[`AST Fixtures > type > TSMappedType > readonly-minus > AST Alignment - AST`] Snapshot Diff: - TSESTree + Babel diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/6-AST-Alignment-Tokens.shot index 7bf5784d4a05..baa98a4a57bc 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-minus/snapshots/6-AST-Alignment-Tokens.shot @@ -1,5 +1,5 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly-minus > AST Alignment - Token`] +exports[`AST Fixtures > type > TSMappedType > readonly-minus > AST Alignment - Token`] Snapshot Diff: Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/1-TSESTree-AST.shot index ce3b5b1785e9..139d4e56d96f 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/1-TSESTree-AST.shot @@ -40,26 +40,26 @@ Program { }, }, nameType: null, - optional: true, + optional: false, readonly: true, typeAnnotation: TSNumberKeyword { type: "TSNumberKeyword", - range: [53, 59], + range: [52, 58], loc: { - start: { column: 27, line: 2 }, - end: { column: 33, line: 2 }, + start: { column: 26, line: 2 }, + end: { column: 32, line: 2 }, }, }, - range: [24, 62], + range: [24, 61], loc: { start: { column: 24, line: 1 }, end: { column: 1, line: 3 }, }, }, - range: [0, 63], + range: [0, 62], loc: { start: { column: 0, line: 1 }, end: { column: 2, line: 3 }, @@ -68,7 +68,7 @@ Program { ], sourceType: "script", - range: [0, 64], + range: [0, 63], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 4 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/2-TSESTree-Tokens.shot index 1dc2635c20ca..93d054f69131 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/2-TSESTree-Tokens.shot @@ -101,7 +101,7 @@ }, Punctuator { type: "Punctuator", - value: "?", + value: ":", range: [50, 51], loc: { @@ -109,41 +109,31 @@ end: { column: 25, line: 2 }, }, }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [51, 52], - loc: { - start: { column: 25, line: 2 }, - end: { column: 26, line: 2 }, - }, - }, Identifier { type: "Identifier", value: "number", - range: [53, 59], + range: [52, 58], loc: { - start: { column: 27, line: 2 }, - end: { column: 33, line: 2 }, + start: { column: 26, line: 2 }, + end: { column: 32, line: 2 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [59, 60], + range: [58, 59], loc: { - start: { column: 33, line: 2 }, - end: { column: 34, line: 2 }, + start: { column: 32, line: 2 }, + end: { column: 33, line: 2 }, }, }, Punctuator { type: "Punctuator", value: "}", - range: [61, 62], + range: [60, 61], loc: { start: { column: 0, line: 3 }, end: { column: 1, line: 3 }, @@ -153,7 +143,7 @@ type: "Punctuator", value: ";", - range: [62, 63], + range: [61, 62], loc: { start: { column: 1, line: 3 }, end: { column: 2, line: 3 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/3-Babel-AST.shot index dcba1b68e86f..11605a809d58 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/3-Babel-AST.shot @@ -16,15 +16,14 @@ Program { typeAnnotation: TSMappedType { type: "TSMappedType", nameType: null, - optional: true, readonly: true, typeAnnotation: TSNumberKeyword { type: "TSNumberKeyword", - range: [53, 59], + range: [52, 58], loc: { - start: { column: 27, line: 2 }, - end: { column: 33, line: 2 }, + start: { column: 26, line: 2 }, + end: { column: 32, line: 2 }, }, }, typeParameter: TSTypeParameter { @@ -47,14 +46,14 @@ Program { }, }, - range: [24, 62], + range: [24, 61], loc: { start: { column: 24, line: 1 }, end: { column: 1, line: 3 }, }, }, - range: [0, 63], + range: [0, 62], loc: { start: { column: 0, line: 1 }, end: { column: 2, line: 3 }, @@ -63,7 +62,7 @@ Program { ], sourceType: "script", - range: [0, 64], + range: [0, 63], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 4 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/4-Babel-Tokens.shot index 1dc2635c20ca..93d054f69131 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/4-Babel-Tokens.shot @@ -101,7 +101,7 @@ }, Punctuator { type: "Punctuator", - value: "?", + value: ":", range: [50, 51], loc: { @@ -109,41 +109,31 @@ end: { column: 25, line: 2 }, }, }, - Punctuator { - type: "Punctuator", - value: ":", - - range: [51, 52], - loc: { - start: { column: 25, line: 2 }, - end: { column: 26, line: 2 }, - }, - }, Identifier { type: "Identifier", value: "number", - range: [53, 59], + range: [52, 58], loc: { - start: { column: 27, line: 2 }, - end: { column: 33, line: 2 }, + start: { column: 26, line: 2 }, + end: { column: 32, line: 2 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [59, 60], + range: [58, 59], loc: { - start: { column: 33, line: 2 }, - end: { column: 34, line: 2 }, + start: { column: 32, line: 2 }, + end: { column: 33, line: 2 }, }, }, Punctuator { type: "Punctuator", value: "}", - range: [61, 62], + range: [60, 61], loc: { start: { column: 0, line: 3 }, end: { column: 1, line: 3 }, @@ -153,7 +143,7 @@ type: "Punctuator", value: ";", - range: [62, 63], + range: [61, 62], loc: { start: { column: 1, line: 3 }, end: { column: 2, line: 3 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/5-AST-Alignment-AST.shot index 68c7e8a9ff0f..4a9202d4d905 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/5-AST-Alignment-AST.shot @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly > AST Alignment - AST`] +exports[`AST Fixtures > type > TSMappedType > readonly-optional > AST Alignment - AST`] Snapshot Diff: - TSESTree + Babel @@ -47,15 +47,15 @@ Snapshot Diff: - }, - }, nameType: null, - optional: true, +- optional: false, readonly: true, typeAnnotation: TSNumberKeyword { type: 'TSNumberKeyword', - range: [53, 59], + range: [52, 58], loc: { - start: { column: 27, line: 2 }, - end: { column: 33, line: 2 }, + start: { column: 26, line: 2 }, + end: { column: 32, line: 2 }, + }, + }, + typeParameter: TSTypeParameter { @@ -78,14 +78,14 @@ Snapshot Diff: }, }, - range: [24, 62], + range: [24, 61], loc: { start: { column: 24, line: 1 }, end: { column: 1, line: 3 }, }, }, - range: [0, 63], + range: [0, 62], loc: { start: { column: 0, line: 1 }, end: { column: 2, line: 3 }, @@ -94,7 +94,7 @@ Snapshot Diff: ], sourceType: 'script', - range: [0, 64], + range: [0, 63], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 4 }, diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/6-AST-Alignment-Tokens.shot index 2bd890ccf742..06340f1bf562 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-optional/snapshots/6-AST-Alignment-Tokens.shot @@ -1,5 +1,5 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly > AST Alignment - Token`] +exports[`AST Fixtures > type > TSMappedType > readonly-optional > AST Alignment - Token`] Snapshot Diff: Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/5-AST-Alignment-AST.shot index 13e2da0777fe..4d6ea7914636 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/5-AST-Alignment-AST.shot @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly-plus > AST Alignment - AST`] +exports[`AST Fixtures > type > TSMappedType > readonly-plus > AST Alignment - AST`] Snapshot Diff: - TSESTree + Babel diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/6-AST-Alignment-Tokens.shot index 5b52d7e4624e..ffe93c7e8277 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly-plus/snapshots/6-AST-Alignment-Tokens.shot @@ -1,5 +1,5 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly-plus > AST Alignment - Token`] +exports[`AST Fixtures > type > TSMappedType > readonly-plus > AST Alignment - Token`] Snapshot Diff: Compared values have no visual difference. diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/5-AST-Alignment-AST.shot index 68c7e8a9ff0f..a3cd43ce9c5f 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/5-AST-Alignment-AST.shot @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly > AST Alignment - AST`] +exports[`AST Fixtures > type > TSMappedType > readonly > AST Alignment - AST`] Snapshot Diff: - TSESTree + Babel diff --git a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/6-AST-Alignment-Tokens.shot index 2bd890ccf742..e2181a65c27f 100644 --- a/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/type/TSMappedType/fixtures/readonly/snapshots/6-AST-Alignment-Tokens.shot @@ -1,5 +1,5 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`AST Fixtures > type > TSMappedType > with-modifiers-readonly > AST Alignment - Token`] +exports[`AST Fixtures > type > TSMappedType > readonly > AST Alignment - Token`] Snapshot Diff: Compared values have no visual difference. diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot index adc389200098..35ac2ec6cf36 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-ast.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot @@ -529,7 +529,8 @@ exports[`AST Fixtures > List fixtures with AST differences`] "type/TSMappedType/fixtures/optional-minus/fixture.ts", "type/TSMappedType/fixtures/optional-plus/fixture.ts", "type/TSMappedType/fixtures/optional/fixture.ts", - "type/TSMappedType/fixtures/with-modifiers-readonly-minus/fixture.ts", - "type/TSMappedType/fixtures/with-modifiers-readonly-plus/fixture.ts", - "type/TSMappedType/fixtures/with-modifiers-readonly/fixture.ts" + "type/TSMappedType/fixtures/readonly-minus/fixture.ts", + "type/TSMappedType/fixtures/readonly-optional/fixture.ts", + "type/TSMappedType/fixtures/readonly-plus/fixture.ts", + "type/TSMappedType/fixtures/readonly/fixture.ts" ]