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 ef00d6dd163a..57cd9d3e565c 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 @@ -21,6 +21,49 @@ Program { }, typeAnnotation: TSMappedType { type: "TSMappedType", + constraint: TSTypeOperator { + type: "TSTypeOperator", + operator: "keyof", + typeAnnotation: TSTypeReference { + type: "TSTypeReference", + typeName: Identifier { + type: "Identifier", + decorators: [], + name: "T", + optional: false, + + range: [104, 105], + loc: { + start: { column: 14, line: 4 }, + end: { column: 15, line: 4 }, + }, + }, + + range: [104, 105], + loc: { + start: { column: 14, line: 4 }, + end: { column: 15, line: 4 }, + }, + }, + + range: [98, 105], + loc: { + start: { column: 8, line: 4 }, + end: { column: 15, line: 4 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [93, 94], + loc: { + start: { column: 3, line: 4 }, + end: { column: 4, line: 4 }, + }, + }, nameType: TSLiteralType { type: "TSLiteralType", literal: Literal { @@ -92,61 +135,6 @@ Program { end: { column: 29, line: 4 }, }, }, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - const: false, - constraint: TSTypeOperator { - type: "TSTypeOperator", - operator: "keyof", - typeAnnotation: TSTypeReference { - type: "TSTypeReference", - typeName: Identifier { - type: "Identifier", - decorators: [], - name: "T", - optional: false, - - range: [104, 105], - loc: { - start: { column: 14, line: 4 }, - end: { column: 15, line: 4 }, - }, - }, - - range: [104, 105], - loc: { - start: { column: 14, line: 4 }, - end: { column: 15, line: 4 }, - }, - }, - - range: [98, 105], - loc: { - start: { column: 8, line: 4 }, - end: { column: 15, line: 4 }, - }, - }, - in: false, - name: Identifier { - type: "Identifier", - decorators: [], - name: "P", - optional: false, - - range: [93, 94], - loc: { - start: { column: 3, line: 4 }, - end: { column: 4, line: 4 }, - }, - }, - out: false, - - range: [93, 105], - 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-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 368c485e82da..3c7484cb3764 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 @@ -25,6 +25,49 @@ exports[`AST Fixtures legacy-fixtures types mapped-named-type AST Alignment - AS }, typeAnnotation: TSMappedType { type: 'TSMappedType', +- constraint: TSTypeOperator { +- type: 'TSTypeOperator', +- operator: 'keyof', +- typeAnnotation: TSTypeReference { +- type: 'TSTypeReference', +- typeName: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'T', +- optional: false, +- +- range: [104, 105], +- loc: { +- start: { column: 14, line: 4 }, +- end: { column: 15, line: 4 }, +- }, +- }, +- +- range: [104, 105], +- loc: { +- start: { column: 14, line: 4 }, +- end: { column: 15, line: 4 }, +- }, +- }, +- +- range: [98, 105], +- loc: { +- start: { column: 8, line: 4 }, +- end: { column: 15, line: 4 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [93, 94], +- loc: { +- start: { column: 3, line: 4 }, +- end: { column: 4, line: 4 }, +- }, +- }, nameType: TSLiteralType { type: 'TSLiteralType', literal: Literal { @@ -96,62 +139,45 @@ exports[`AST Fixtures legacy-fixtures types mapped-named-type AST Alignment - AS end: { column: 29, line: 4 }, }, }, - typeParameter: TSTypeParameter { - type: 'TSTypeParameter', -- const: false, - constraint: TSTypeOperator { - type: 'TSTypeOperator', - operator: 'keyof', - typeAnnotation: TSTypeReference { - type: 'TSTypeReference', - typeName: Identifier { - type: 'Identifier', -- decorators: Array [], - name: 'T', -- optional: false, - - range: [104, 105], - loc: { - start: { column: 14, line: 4 }, - end: { column: 15, line: 4 }, - }, - }, - - range: [104, 105], - loc: { - start: { column: 14, line: 4 }, - end: { column: 15, line: 4 }, - }, - }, - - range: [98, 105], - loc: { - start: { column: 8, line: 4 }, - end: { column: 15, line: 4 }, - }, - }, -- in: false, -- name: Identifier { -- type: 'Identifier', -- decorators: Array [], -- name: 'P', -- optional: false, -- -- range: [93, 94], -- loc: { -- start: { column: 3, line: 4 }, -- end: { column: 4, line: 4 }, -- }, -- }, -- out: false, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSTypeOperator { ++ type: 'TSTypeOperator', ++ operator: 'keyof', ++ typeAnnotation: TSTypeReference { ++ type: 'TSTypeReference', ++ typeName: Identifier { ++ type: 'Identifier', ++ name: 'T', ++ ++ range: [104, 105], ++ loc: { ++ start: { column: 14, line: 4 }, ++ end: { column: 15, line: 4 }, ++ }, ++ }, ++ ++ range: [104, 105], ++ loc: { ++ start: { column: 14, line: 4 }, ++ end: { column: 15, line: 4 }, ++ }, ++ }, ++ ++ range: [98, 105], ++ loc: { ++ start: { column: 8, line: 4 }, ++ end: { column: 15, line: 4 }, ++ }, ++ }, + name: 'P', - - range: [93, 105], - loc: { - start: { column: 3, line: 4 }, - end: { column: 15, line: 4 }, - }, - }, ++ ++ range: [93, 105], ++ 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-readonly-minus/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-minus/snapshots/1-TSESTree-AST.shot index 5e7781c3ef65..3ddeb8b5a60c 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-minus/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-minus/snapshots/1-TSESTree-AST.shot @@ -19,6 +19,27 @@ Program { type: "TSTypeAnnotation", typeAnnotation: TSMappedType { type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [100, 106], + loc: { + start: { column: 27, line: 3 }, + end: { column: 33, line: 3 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [95, 96], + loc: { + start: { column: 22, line: 3 }, + end: { column: 23, line: 3 }, + }, + }, nameType: null, optional: "-", readonly: "-", @@ -31,39 +52,6 @@ Program { end: { column: 44, line: 3 }, }, }, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - const: false, - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [100, 106], - loc: { - start: { column: 27, line: 3 }, - end: { column: 33, line: 3 }, - }, - }, - in: false, - name: Identifier { - type: "Identifier", - decorators: [], - name: "P", - optional: false, - - range: [95, 96], - loc: { - start: { column: 22, line: 3 }, - end: { column: 23, line: 3 }, - }, - }, - out: false, - - range: [95, 106], - loc: { - start: { column: 22, line: 3 }, - end: { column: 33, line: 3 }, - }, - }, range: [82, 119], loc: { diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-minus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-minus/snapshots/5-AST-Alignment-AST.shot index 5a1e7b20c516..be92a34ed653 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-minus/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-minus/snapshots/5-AST-Alignment-AST.shot @@ -23,6 +23,27 @@ exports[`AST Fixtures legacy-fixtures types mapped-readonly-minus AST Alignment type: 'TSTypeAnnotation', typeAnnotation: TSMappedType { type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [100, 106], +- loc: { +- start: { column: 27, line: 3 }, +- end: { column: 33, line: 3 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [95, 96], +- loc: { +- start: { column: 22, line: 3 }, +- end: { column: 23, line: 3 }, +- }, +- }, nameType: null, optional: '-', readonly: '-', @@ -35,41 +56,26 @@ exports[`AST Fixtures legacy-fixtures types mapped-readonly-minus AST Alignment end: { column: 44, line: 3 }, }, }, - typeParameter: TSTypeParameter { - type: 'TSTypeParameter', -- const: false, - constraint: TSStringKeyword { - type: 'TSStringKeyword', ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', - range: [100, 106], - loc: { - start: { column: 27, line: 3 }, - end: { column: 33, line: 3 }, - }, - }, -- in: false, -- name: Identifier { -- type: 'Identifier', -- decorators: Array [], -- name: 'P', -- optional: false, ++ range: [100, 106], ++ loc: { ++ start: { column: 27, line: 3 }, ++ end: { column: 33, line: 3 }, ++ }, ++ }, + name: 'P', - -- range: [95, 96], -- loc: { -- start: { column: 22, line: 3 }, -- end: { column: 23, line: 3 }, -- }, -- }, -- out: false, -- - range: [95, 106], - loc: { - start: { column: 22, line: 3 }, - end: { column: 33, line: 3 }, - }, - }, - ++ ++ range: [95, 106], ++ loc: { ++ start: { column: 22, line: 3 }, ++ end: { column: 33, line: 3 }, ++ }, ++ }, ++ range: [82, 119], loc: { start: { column: 9, line: 3 }, diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-plus/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-plus/snapshots/1-TSESTree-AST.shot index fcdef4d6c306..0f3690a03bbb 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-plus/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-plus/snapshots/1-TSESTree-AST.shot @@ -19,6 +19,27 @@ Program { type: "TSTypeAnnotation", typeAnnotation: TSMappedType { type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [100, 106], + loc: { + start: { column: 27, line: 3 }, + end: { column: 33, line: 3 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [95, 96], + loc: { + start: { column: 22, line: 3 }, + end: { column: 23, line: 3 }, + }, + }, nameType: null, optional: "+", readonly: "+", @@ -31,39 +52,6 @@ Program { end: { column: 44, line: 3 }, }, }, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - const: false, - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [100, 106], - loc: { - start: { column: 27, line: 3 }, - end: { column: 33, line: 3 }, - }, - }, - in: false, - name: Identifier { - type: "Identifier", - decorators: [], - name: "P", - optional: false, - - range: [95, 96], - loc: { - start: { column: 22, line: 3 }, - end: { column: 23, line: 3 }, - }, - }, - out: false, - - range: [95, 106], - loc: { - start: { column: 22, line: 3 }, - end: { column: 33, line: 3 }, - }, - }, range: [82, 119], loc: { diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-plus/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-plus/snapshots/5-AST-Alignment-AST.shot index 6beae1721224..9dd0ad409179 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-plus/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly-plus/snapshots/5-AST-Alignment-AST.shot @@ -23,6 +23,27 @@ exports[`AST Fixtures legacy-fixtures types mapped-readonly-plus AST Alignment - type: 'TSTypeAnnotation', typeAnnotation: TSMappedType { type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [100, 106], +- loc: { +- start: { column: 27, line: 3 }, +- end: { column: 33, line: 3 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [95, 96], +- loc: { +- start: { column: 22, line: 3 }, +- end: { column: 23, line: 3 }, +- }, +- }, nameType: null, optional: '+', readonly: '+', @@ -35,41 +56,26 @@ exports[`AST Fixtures legacy-fixtures types mapped-readonly-plus AST Alignment - end: { column: 44, line: 3 }, }, }, - typeParameter: TSTypeParameter { - type: 'TSTypeParameter', -- const: false, - constraint: TSStringKeyword { - type: 'TSStringKeyword', ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', - range: [100, 106], - loc: { - start: { column: 27, line: 3 }, - end: { column: 33, line: 3 }, - }, - }, -- in: false, -- name: Identifier { -- type: 'Identifier', -- decorators: Array [], -- name: 'P', -- optional: false, ++ range: [100, 106], ++ loc: { ++ start: { column: 27, line: 3 }, ++ end: { column: 33, line: 3 }, ++ }, ++ }, + name: 'P', - -- range: [95, 96], -- loc: { -- start: { column: 22, line: 3 }, -- end: { column: 23, line: 3 }, -- }, -- }, -- out: false, -- - range: [95, 106], - loc: { - start: { column: 22, line: 3 }, - end: { column: 33, line: 3 }, - }, - }, - ++ ++ range: [95, 106], ++ loc: { ++ start: { column: 22, line: 3 }, ++ end: { column: 33, line: 3 }, ++ }, ++ }, ++ range: [82, 119], loc: { start: { column: 9, line: 3 }, diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly/snapshots/1-TSESTree-AST.shot index f70b1ed6956b..c28ad65a923f 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly/snapshots/1-TSESTree-AST.shot @@ -19,6 +19,27 @@ Program { type: "TSTypeAnnotation", typeAnnotation: TSMappedType { type: "TSMappedType", + constraint: TSStringKeyword { + type: "TSStringKeyword", + + range: [99, 105], + loc: { + start: { column: 26, line: 3 }, + end: { column: 32, line: 3 }, + }, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, + + range: [94, 95], + loc: { + start: { column: 21, line: 3 }, + end: { column: 22, line: 3 }, + }, + }, nameType: null, optional: true, readonly: true, @@ -31,39 +52,6 @@ Program { end: { column: 42, line: 3 }, }, }, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - const: false, - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [99, 105], - loc: { - start: { column: 26, line: 3 }, - end: { column: 32, line: 3 }, - }, - }, - in: false, - name: Identifier { - type: "Identifier", - decorators: [], - name: "P", - optional: false, - - range: [94, 95], - loc: { - start: { column: 21, line: 3 }, - end: { column: 22, line: 3 }, - }, - }, - out: false, - - range: [94, 105], - loc: { - start: { column: 21, line: 3 }, - end: { column: 32, line: 3 }, - }, - }, range: [82, 117], loc: { diff --git a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly/snapshots/5-AST-Alignment-AST.shot index 8c8500647fd6..af26bcceb36b 100644 --- a/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/legacy-fixtures/types/fixtures/mapped-readonly/snapshots/5-AST-Alignment-AST.shot @@ -23,6 +23,27 @@ exports[`AST Fixtures legacy-fixtures types mapped-readonly AST Alignment - AST type: 'TSTypeAnnotation', typeAnnotation: TSMappedType { type: 'TSMappedType', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', +- +- range: [99, 105], +- loc: { +- start: { column: 26, line: 3 }, +- end: { column: 32, line: 3 }, +- }, +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], +- name: 'P', +- optional: false, +- +- range: [94, 95], +- loc: { +- start: { column: 21, line: 3 }, +- end: { column: 22, line: 3 }, +- }, +- }, nameType: null, optional: true, readonly: true, @@ -35,41 +56,26 @@ exports[`AST Fixtures legacy-fixtures types mapped-readonly AST Alignment - AST end: { column: 42, line: 3 }, }, }, - typeParameter: TSTypeParameter { - type: 'TSTypeParameter', -- const: false, - constraint: TSStringKeyword { - type: 'TSStringKeyword', ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', - range: [99, 105], - loc: { - start: { column: 26, line: 3 }, - end: { column: 32, line: 3 }, - }, - }, -- in: false, -- name: Identifier { -- type: 'Identifier', -- decorators: Array [], -- name: 'P', -- optional: false, ++ range: [99, 105], ++ loc: { ++ start: { column: 26, line: 3 }, ++ end: { column: 32, line: 3 }, ++ }, ++ }, + name: 'P', - -- range: [94, 95], -- loc: { -- start: { column: 21, line: 3 }, -- end: { column: 22, line: 3 }, -- }, -- }, -- out: false, -- - range: [94, 105], - loc: { - start: { column: 21, line: 3 }, - end: { column: 32, line: 3 }, - }, - }, - ++ ++ range: [94, 105], ++ loc: { ++ start: { column: 21, line: 3 }, ++ end: { column: 32, line: 3 }, ++ }, ++ }, ++ range: [82, 117], loc: { start: { column: 9, line: 3 }, 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 d57cfcd0f424..09ca20f18bf2 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 @@ -19,40 +19,28 @@ Program { type: "TSTypeAnnotation", typeAnnotation: TSMappedType { type: "TSMappedType", - nameType: null, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - const: false, - constraint: TSStringKeyword { - type: "TSStringKeyword", - - range: [90, 96], - loc: { - start: { column: 17, line: 3 }, - end: { column: 23, line: 3 }, - }, - }, - in: false, - name: Identifier { - type: "Identifier", - decorators: [], - name: "P", - optional: false, + constraint: TSStringKeyword { + type: "TSStringKeyword", - range: [85, 86], - loc: { - start: { column: 12, line: 3 }, - end: { column: 13, line: 3 }, - }, + range: [90, 96], + loc: { + start: { column: 17, line: 3 }, + end: { column: 23, line: 3 }, }, - out: false, + }, + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, - range: [85, 96], + range: [85, 86], loc: { start: { column: 12, line: 3 }, - end: { column: 23, line: 3 }, + end: { column: 13, line: 3 }, }, }, + nameType: null, 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 5af936438b5b..7dd7abd04846 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 @@ -23,41 +23,40 @@ exports[`AST Fixtures legacy-fixtures types mapped-untypped AST Alignment - AST type: 'TSTypeAnnotation', typeAnnotation: TSMappedType { type: 'TSMappedType', - nameType: null, - typeParameter: TSTypeParameter { - type: 'TSTypeParameter', -- const: false, - constraint: TSStringKeyword { - type: 'TSStringKeyword', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', ++ nameType: null, ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', - range: [90, 96], - loc: { - start: { column: 17, line: 3 }, - end: { column: 23, line: 3 }, - }, +- range: [90, 96], +- loc: { +- start: { column: 17, line: 3 }, +- end: { column: 23, line: 3 }, ++ range: [90, 96], ++ loc: { ++ start: { column: 17, line: 3 }, ++ end: { column: 23, line: 3 }, ++ }, }, -- in: false, -- name: Identifier { -- type: 'Identifier', -- decorators: Array [], -- name: 'P', -- optional: false, -+ name: 'P', +- }, +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], + name: 'P', +- optional: false, -- range: [85, 86], -- loc: { -- start: { column: 12, line: 3 }, -- end: { column: 13, line: 3 }, -- }, -- }, -- out: false, -- - range: [85, 96], +- range: [85, 86], ++ range: [85, 96], loc: { start: { column: 12, line: 3 }, - end: { column: 23, line: 3 }, +- end: { column: 13, line: 3 }, ++ end: { column: 23, line: 3 }, }, }, +- nameType: null, 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 82119bfda8e2..98ccc34fe16a 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 @@ -19,47 +19,35 @@ Program { type: "TSTypeAnnotation", typeAnnotation: TSMappedType { type: "TSMappedType", - nameType: null, - typeAnnotation: TSNumberKeyword { - type: "TSNumberKeyword", + constraint: TSStringKeyword { + type: "TSStringKeyword", - range: [99, 105], + range: [90, 96], loc: { - start: { column: 26, line: 3 }, - end: { column: 32, line: 3 }, + start: { column: 17, line: 3 }, + end: { column: 23, line: 3 }, }, }, - typeParameter: TSTypeParameter { - type: "TSTypeParameter", - const: false, - constraint: TSStringKeyword { - type: "TSStringKeyword", + key: Identifier { + type: "Identifier", + decorators: [], + name: "P", + optional: false, - range: [90, 96], - loc: { - start: { column: 17, line: 3 }, - end: { column: 23, line: 3 }, - }, - }, - in: false, - name: Identifier { - type: "Identifier", - decorators: [], - name: "P", - optional: false, - - range: [85, 86], - loc: { - start: { column: 12, line: 3 }, - end: { column: 13, line: 3 }, - }, + range: [85, 86], + loc: { + start: { column: 12, line: 3 }, + end: { column: 13, line: 3 }, }, - out: false, + }, + nameType: null, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", - range: [85, 96], + range: [99, 105], loc: { - start: { column: 12, line: 3 }, - end: { column: 23, line: 3 }, + start: { column: 26, line: 3 }, + end: { column: 32, line: 3 }, }, }, 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 2fcdfabe0986..62e39e79d426 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 @@ -23,48 +23,54 @@ exports[`AST Fixtures legacy-fixtures types mapped AST Alignment - AST 1`] = ` type: 'TSTypeAnnotation', typeAnnotation: TSMappedType { type: 'TSMappedType', - nameType: null, - typeAnnotation: TSNumberKeyword { - type: 'TSNumberKeyword', +- constraint: TSStringKeyword { +- type: 'TSStringKeyword', ++ nameType: null, ++ typeAnnotation: TSNumberKeyword { ++ type: 'TSNumberKeyword', - range: [99, 105], +- range: [90, 96], ++ range: [99, 105], loc: { - start: { column: 26, line: 3 }, - end: { column: 32, line: 3 }, +- start: { column: 17, line: 3 }, +- end: { column: 23, line: 3 }, ++ start: { column: 26, line: 3 }, ++ end: { column: 32, line: 3 }, }, }, - typeParameter: TSTypeParameter { - type: 'TSTypeParameter', -- const: false, - constraint: TSStringKeyword { - type: 'TSStringKeyword', +- key: Identifier { +- type: 'Identifier', +- decorators: Array [], ++ typeParameter: TSTypeParameter { ++ type: 'TSTypeParameter', ++ constraint: TSStringKeyword { ++ type: 'TSStringKeyword', ++ ++ range: [90, 96], ++ loc: { ++ start: { column: 17, line: 3 }, ++ end: { column: 23, line: 3 }, ++ }, ++ }, + name: 'P', +- optional: false, - range: [90, 96], - loc: { - start: { column: 17, line: 3 }, - end: { column: 23, line: 3 }, - }, - }, -- in: false, -- name: Identifier { -- type: 'Identifier', -- decorators: Array [], -- name: 'P', -- optional: false, -+ name: 'P', - -- range: [85, 86], -- loc: { -- start: { column: 12, line: 3 }, -- end: { column: 13, line: 3 }, -- }, -- }, -- out: false, -- - range: [85, 96], +- range: [85, 86], ++ range: [85, 96], loc: { start: { column: 12, line: 3 }, - end: { column: 23, 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 }, ++ end: { column: 23, line: 3 }, }, }, diff --git a/packages/ast-spec/src/type/TSMappedType/spec.ts b/packages/ast-spec/src/type/TSMappedType/spec.ts index 8b81c4f77bb6..44f64ac8621a 100644 --- a/packages/ast-spec/src/type/TSMappedType/spec.ts +++ b/packages/ast-spec/src/type/TSMappedType/spec.ts @@ -1,11 +1,17 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { BaseNode } from '../../base/BaseNode'; +import type { Identifier } from '../../expression/Identifier/spec'; import type { TSTypeParameter } from '../../special/TSTypeParameter/spec'; import type { TypeNode } from '../../unions/TypeNode'; export interface TSMappedType extends BaseNode { type: AST_NODE_TYPES.TSMappedType; + + /** @deprecated Use {@link `constraint`} and {@link `key`} instead. */ typeParameter: TSTypeParameter; + + constraint: TypeNode; + key: Identifier; readonly: boolean | '-' | '+' | undefined; optional: boolean | '-' | '+' | undefined; typeAnnotation: TypeNode | undefined; diff --git a/packages/eslint-plugin/src/rules/indent.ts b/packages/eslint-plugin/src/rules/indent.ts index 544e3dbdc826..8fc8a4191a9c 100644 --- a/packages/eslint-plugin/src/rules/indent.ts +++ b/packages/eslint-plugin/src/rules/indent.ts @@ -383,6 +383,7 @@ export default createRule({ TSMappedType(node: TSESTree.TSMappedType) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const squareBracketStart = context.sourceCode.getTokenBefore( + // eslint-disable-next-line deprecation/deprecation node.typeParameter, )!; @@ -393,6 +394,7 @@ export default createRule({ { parent: node, type: AST_NODE_TYPES.Property, + // eslint-disable-next-line deprecation/deprecation key: node.typeParameter as any, value: node.typeAnnotation as any, diff --git a/packages/eslint-plugin/src/util/collectUnusedVariables.ts b/packages/eslint-plugin/src/util/collectUnusedVariables.ts index 54a4e91750a4..443167a3e3c0 100644 --- a/packages/eslint-plugin/src/util/collectUnusedVariables.ts +++ b/packages/eslint-plugin/src/util/collectUnusedVariables.ts @@ -317,7 +317,7 @@ class UnusedVarsVisitor< protected TSMappedType(node: TSESTree.TSMappedType): void { // mapped types create a variable for their type name, but it's not necessary to reference it, // so we shouldn't consider it as unused for the purpose of this rule. - this.markVariableAsUsed(node.typeParameter.name); + this.markVariableAsUsed(node.key); } protected TSMethodSignature = this.visitFunctionTypeSignature; diff --git a/packages/scope-manager/src/definition/TypeDefinition.ts b/packages/scope-manager/src/definition/TypeDefinition.ts index 506274d42734..75de333bb0ad 100644 --- a/packages/scope-manager/src/definition/TypeDefinition.ts +++ b/packages/scope-manager/src/definition/TypeDefinition.ts @@ -6,6 +6,7 @@ import { DefinitionType } from './DefinitionType'; class TypeDefinition extends DefinitionBase< DefinitionType.Type, | TSESTree.TSInterfaceDeclaration + | TSESTree.TSMappedType | TSESTree.TSTypeAliasDeclaration | TSESTree.TSTypeParameter, null, diff --git a/packages/scope-manager/src/referencer/TypeVisitor.ts b/packages/scope-manager/src/referencer/TypeVisitor.ts index 778b2d673336..ab3b8a0b1bf4 100644 --- a/packages/scope-manager/src/referencer/TypeVisitor.ts +++ b/packages/scope-manager/src/referencer/TypeVisitor.ts @@ -199,7 +199,12 @@ class TypeVisitor extends Visitor { protected TSMappedType(node: TSESTree.TSMappedType): void { // mapped types key can only be referenced within their return value this.#referencer.scopeManager.nestMappedTypeScope(node); - this.visitChildren(node); + this.#referencer + .currentScope() + .defineIdentifier(node.key, new TypeDefinition(node.key, node)); + this.visit(node.constraint); + this.visit(node.nameType); + this.visit(node.typeAnnotation); this.#referencer.close(node); } diff --git a/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-no-references.ts b/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-no-references.ts new file mode 100644 index 000000000000..3ae8ec6a9176 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-no-references.ts @@ -0,0 +1,2 @@ +type T = 1; +type M = { [T in string as T]: 1 }; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-no-references.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-no-references.ts.shot new file mode 100644 index 000000000000..cbb18cc721b7 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-no-references.ts.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration mapped-named-literal-no-references 1`] = ` +ScopeManager { + variables: [ + ImplicitGlobalConstTypeVariable, + Variable$2 { + defs: [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: [ + TypeDefinition$2 { + name: Identifier<"M">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "M", + references: [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: [ + TypeDefinition$3 { + name: Identifier<"T">, + node: TSMappedType$3, + }, + ], + name: "T", + references: [ + Reference$1 { + identifier: Identifier<"T">, + isRead: true, + isTypeReference: true, + isValueReference: false, + isWrite: false, + resolved: Variable$4, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: [], + set: Map { + "const" => ImplicitGlobalConstTypeVariable, + "T" => Variable$2, + "M" => Variable$3, + }, + type: "global", + upper: null, + variables: [ + ImplicitGlobalConstTypeVariable, + Variable$2, + Variable$3, + ], + }, + MappedTypeScope$2 { + block: TSMappedType$3, + isStrict: true, + references: [ + Reference$1, + ], + set: Map { + "T" => Variable$4, + }, + type: "mappedType", + upper: GlobalScope$1, + variables: [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-referenced.ts b/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-referenced.ts new file mode 100644 index 000000000000..a7b4c95de066 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-referenced.ts @@ -0,0 +1,2 @@ +type T = 1; // should have 1 reference +type M = { [K in string as T]: 1 }; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-referenced.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-referenced.ts.shot new file mode 100644 index 000000000000..c1b6bd45a180 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/mapped-named-literal-referenced.ts.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration mapped-named-literal-referenced 1`] = ` +ScopeManager { + variables: [ + ImplicitGlobalConstTypeVariable, + Variable$2 { + defs: [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: [ + Reference$1 { + identifier: Identifier<"T">, + isRead: true, + isTypeReference: true, + isValueReference: false, + isWrite: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: [ + TypeDefinition$2 { + name: Identifier<"M">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "M", + references: [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: [ + TypeDefinition$3 { + name: Identifier<"K">, + node: TSMappedType$3, + }, + ], + name: "K", + references: [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: [], + set: Map { + "const" => ImplicitGlobalConstTypeVariable, + "T" => Variable$2, + "M" => Variable$3, + }, + type: "global", + upper: null, + variables: [ + ImplicitGlobalConstTypeVariable, + Variable$2, + Variable$3, + ], + }, + MappedTypeScope$2 { + block: TSMappedType$3, + isStrict: true, + references: [ + Reference$1, + ], + set: Map { + "K" => Variable$4, + }, + type: "mappedType", + upper: GlobalScope$1, + variables: [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/mapped-named.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/mapped-named.ts.shot index c5e5927384fc..11aa7739cb76 100644 --- a/packages/scope-manager/tests/fixtures/type-declaration/mapped-named.ts.shot +++ b/packages/scope-manager/tests/fixtures/type-declaration/mapped-named.ts.shot @@ -41,7 +41,7 @@ ScopeManager { defs: [ TypeDefinition$3 { name: Identifier<"k">, - node: TSTypeParameter$3, + node: TSMappedType$3, }, ], name: "k", @@ -95,7 +95,7 @@ ScopeManager { ], }, MappedTypeScope$2 { - block: TSMappedType$5, + block: TSMappedType$3, isStrict: true, references: [ Reference$2, diff --git a/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts.shot index 6790ca3dd92c..59aab2c5e1de 100644 --- a/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts.shot +++ b/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts.shot @@ -41,7 +41,7 @@ ScopeManager { defs: [ TypeDefinition$3 { name: Identifier<"k">, - node: TSTypeParameter$3, + node: TSMappedType$3, }, ], name: "k", @@ -87,7 +87,7 @@ ScopeManager { ], }, MappedTypeScope$2 { - block: TSMappedType$5, + block: TSMappedType$3, isStrict: true, references: [ Reference$2, diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index c2cf7c2c8bb2..5ffe6008d7d2 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2639,20 +2639,29 @@ export class Converter { ); } - return this.createNode(node, { - type: AST_NODE_TYPES.TSMappedType, - 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)), - typeAnnotation: node.type && this.convertChild(node.type), - typeParameter: this.convertChild(node.typeParameter), - }); + return this.createNode( + node, + this.#withDeprecatedGetter( + { + type: AST_NODE_TYPES.TSMappedType, + 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)), + typeAnnotation: node.type && this.convertChild(node.type), + }, + 'typeParameter', + "'constraint' and 'key'", + this.convertChild(node.typeParameter), + ), + ); } case SyntaxKind.ParenthesizedExpression: @@ -2912,7 +2921,7 @@ export class Converter { id: this.convertChild(node.name), }, 'members', - 'body.members', + `'body.members'`, node.members.map(el => this.convertChild(el)), ), ); @@ -3550,7 +3559,7 @@ export class Converter { : (): Value => { if (!warned) { process.emitWarning( - `The '${deprecatedKey}' property is deprecated on ${node.type} nodes. Use '${preferredKey}' instead. See https://typescript-eslint.io/linting/troubleshooting#the-key-property-is-deprecated-on-type-nodes-use-key-instead-warnings.`, + `The '${deprecatedKey}' property is deprecated on ${node.type} nodes. Use ${preferredKey} instead. See https://typescript-eslint.io/linting/troubleshooting#the-key-property-is-deprecated-on-type-nodes-use-key-instead-warnings.`, 'DeprecationWarning', ); warned = true; diff --git a/packages/typescript-estree/tests/lib/convert.test.ts b/packages/typescript-estree/tests/lib/convert.test.ts index 9988c969b6a7..640a3d9946ab 100644 --- a/packages/typescript-estree/tests/lib/convert.test.ts +++ b/packages/typescript-estree/tests/lib/convert.test.ts @@ -297,7 +297,29 @@ describe('convert', () => { return maps.tsNodeToESTreeNodeMap.get(tsCallExpression); }; - it('warns on a deprecated property access when suppressDeprecatedPropertyWarnings is false', () => { + const getTsMappedType = ( + converterOptions?: ConverterOptions, + ): TSESTree.TSMappedType => { + const ast = convertCode(` + type MappedType = { + [Key in Type]: Value; + }; + `); + const tsMappedType = (ast.statements[0] as ts.TypeAliasDeclaration) + .type as ts.MappedTypeNode; + const instance = new Converter(ast, { + shouldPreserveNodeMaps: true, + ...converterOptions, + }); + + instance.convertProgram(); + + const maps = instance.getASTMaps(); + + return maps.tsNodeToESTreeNodeMap.get(tsMappedType); + }; + + it('warns on a deprecated aliased property access when suppressDeprecatedPropertyWarnings is false', () => { const emitWarning = jest .spyOn(process, 'emitWarning') .mockImplementation(); @@ -314,7 +336,7 @@ describe('convert', () => { ); }); - it('does not warn on a subsequent deprecated property access when suppressDeprecatedPropertyWarnings is false', () => { + it('does not warn on a subsequent deprecated aliased property access when suppressDeprecatedPropertyWarnings is false', () => { const emitWarning = jest .spyOn(process, 'emitWarning') .mockImplementation(); @@ -330,7 +352,7 @@ describe('convert', () => { expect(emitWarning).toHaveBeenCalledTimes(1); }); - it('does not warn on a deprecated property access when suppressDeprecatedPropertyWarnings is true', () => { + it('does not warn on a deprecated aliased property access when suppressDeprecatedPropertyWarnings is true', () => { const emitWarning = jest .spyOn(process, 'emitWarning') .mockImplementation(); @@ -344,13 +366,13 @@ describe('convert', () => { expect(emitWarning).not.toHaveBeenCalled(); }); - it('does not allow enumeration of deprecated properties', () => { + it('does not allow enumeration of deprecated aliased properties', () => { const esCallExpression = getEsCallExpression(); expect(Object.keys(esCallExpression)).not.toContain('typeParameters'); }); - it('allows writing to the deprecated property as a new enumerable value', () => { + it('allows writing to the deprecated aliased property as a new enumerable value', () => { const esCallExpression = getEsCallExpression(); // eslint-disable-next-line deprecation/deprecation @@ -360,5 +382,69 @@ describe('convert', () => { expect(esCallExpression.typeParameters).toBeUndefined(); expect(Object.keys(esCallExpression)).toContain('typeParameters'); }); + + it('warns on a deprecated getter property access when suppressDeprecatedPropertyWarnings is false', () => { + const emitWarning = jest + .spyOn(process, 'emitWarning') + .mockImplementation(); + const tsMappedType = getTsMappedType({ + suppressDeprecatedPropertyWarnings: false, + }); + + // eslint-disable-next-line deprecation/deprecation + tsMappedType.typeParameter; + + expect(emitWarning).toHaveBeenCalledWith( + `The 'typeParameter' property is deprecated on TSMappedType nodes. Use 'constraint' and 'key' instead. See https://typescript-eslint.io/linting/troubleshooting#the-key-property-is-deprecated-on-type-nodes-use-key-instead-warnings.`, + 'DeprecationWarning', + ); + }); + + it('does not warn on a subsequent deprecated getter property access when suppressDeprecatedPropertyWarnings is false', () => { + const emitWarning = jest + .spyOn(process, 'emitWarning') + .mockImplementation(); + const tsMappedType = getTsMappedType({ + suppressDeprecatedPropertyWarnings: false, + }); + + /* eslint-disable deprecation/deprecation */ + tsMappedType.typeParameter; + tsMappedType.typeParameter; + /* eslint-enable deprecation/deprecation */ + + expect(emitWarning).toHaveBeenCalledTimes(1); + }); + + it('does not warn on a deprecated getter property access when suppressDeprecatedPropertyWarnings is true', () => { + const emitWarning = jest + .spyOn(process, 'emitWarning') + .mockImplementation(); + const tsMappedType = getTsMappedType({ + suppressDeprecatedPropertyWarnings: true, + }); + + // eslint-disable-next-line deprecation/deprecation + tsMappedType.typeParameter; + + expect(emitWarning).not.toHaveBeenCalled(); + }); + + it('does not allow enumeration of deprecated getter properties', () => { + const tsMappedType = getTsMappedType(); + + expect(Object.keys(tsMappedType)).not.toContain('typeParameter'); + }); + + it('allows writing to the deprecated getter property as a new enumerable value', () => { + const tsMappedType = getTsMappedType(); + + // eslint-disable-next-line deprecation/deprecation + tsMappedType.typeParameter = undefined!; + + // eslint-disable-next-line deprecation/deprecation + expect(tsMappedType.typeParameter).toBeUndefined(); + expect(Object.keys(tsMappedType)).toContain('typeParameter'); + }); }); }); diff --git a/packages/visitor-keys/src/visitor-keys.ts b/packages/visitor-keys/src/visitor-keys.ts index c849790dbb52..fca073dd2a59 100644 --- a/packages/visitor-keys/src/visitor-keys.ts +++ b/packages/visitor-keys/src/visitor-keys.ts @@ -225,7 +225,7 @@ const additionalKeys: AdditionalKeys = { TSIntersectionType: ['types'], TSIntrinsicKeyword: [], TSLiteralType: ['literal'], - TSMappedType: ['nameType', 'typeParameter', 'typeAnnotation'], + TSMappedType: ['key', 'constraint', 'nameType', 'typeAnnotation'], TSMethodSignature: ['typeParameters', 'key', 'params', 'returnType'], TSModuleBlock: ['body'], TSModuleDeclaration: ['id', 'body'],