From f66458bf27c27a10e6d146d604602fcb1e61653f Mon Sep 17 00:00:00 2001 From: sonallux <13821543+sonallux@users.noreply.github.com> Date: Mon, 10 May 2021 16:02:12 +0200 Subject: [PATCH] feat!: remove `TSParenthesizedType` fixes #3136 --- packages/ast-spec/src/ast-node-types.ts | 1 - .../src/type/TSParenthesizedType/spec.ts | 8 -- packages/ast-spec/src/type/spec.ts | 1 - packages/ast-spec/src/unions/Node.ts | 2 - packages/ast-spec/src/unions/TypeNode.ts | 2 - .../eslint-plugin/src/rules/array-type.ts | 22 ++--- .../src/rules/indent-new-do-not-use/index.ts | 1 - packages/eslint-plugin/src/rules/indent.ts | 1 - .../src/rules/no-extra-parens.ts | 4 +- .../eslint-plugin/src/rules/no-type-alias.ts | 3 - .../sort-type-union-intersection-members.ts | 9 +- .../tests/rules/indent/indent.test.ts | 23 ----- .../tests/rules/no-extra-parens.test.ts | 2 +- ...rt-type-union-intersection-members.test.ts | 2 +- .../experimental-utils/src/ts-eslint/Rule.ts | 1 - packages/typescript-estree/src/convert.ts | 5 +- .../src/ts-estree/estree-to-ts-node-types.ts | 1 - .../tests/ast-alignment/utils.ts | 10 +++ .../conditional-infer-nested.src.ts.shot | 51 ++++------- .../types/conditional-infer.src.ts.shot | 51 ++++------- .../types/parenthesized-type.src.ts.shot | 89 ++++++++----------- .../types/tuple-named-optional.src.ts.shot | 89 ++++++++----------- .../types/tuple-optional.src.ts.shot | 89 ++++++++----------- packages/visitor-keys/src/visitor-keys.ts | 1 - 24 files changed, 169 insertions(+), 299 deletions(-) delete mode 100644 packages/ast-spec/src/type/TSParenthesizedType/spec.ts diff --git a/packages/ast-spec/src/ast-node-types.ts b/packages/ast-spec/src/ast-node-types.ts index 6aa0087d5eb2..e1bbf05b1161 100644 --- a/packages/ast-spec/src/ast-node-types.ts +++ b/packages/ast-spec/src/ast-node-types.ts @@ -134,7 +134,6 @@ export enum AST_NODE_TYPES { TSObjectKeyword = 'TSObjectKeyword', TSOptionalType = 'TSOptionalType', TSParameterProperty = 'TSParameterProperty', - TSParenthesizedType = 'TSParenthesizedType', TSPrivateKeyword = 'TSPrivateKeyword', TSPropertySignature = 'TSPropertySignature', TSProtectedKeyword = 'TSProtectedKeyword', diff --git a/packages/ast-spec/src/type/TSParenthesizedType/spec.ts b/packages/ast-spec/src/type/TSParenthesizedType/spec.ts deleted file mode 100644 index 2d20d5d2f2bc..000000000000 --- a/packages/ast-spec/src/type/TSParenthesizedType/spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { AST_NODE_TYPES } from '../../ast-node-types'; -import type { BaseNode } from '../../base/BaseNode'; -import type { TypeNode } from '../../unions/TypeNode'; - -export interface TSParenthesizedType extends BaseNode { - type: AST_NODE_TYPES.TSParenthesizedType; - typeAnnotation: TypeNode; -} diff --git a/packages/ast-spec/src/type/spec.ts b/packages/ast-spec/src/type/spec.ts index bbbea76cbd8e..d6209d260673 100644 --- a/packages/ast-spec/src/type/spec.ts +++ b/packages/ast-spec/src/type/spec.ts @@ -17,7 +17,6 @@ export * from './TSNullKeyword/spec'; export * from './TSNumberKeyword/spec'; export * from './TSObjectKeyword/spec'; export * from './TSOptionalType/spec'; -export * from './TSParenthesizedType/spec'; export * from './TSQualifiedName/spec'; export * from './TSRestType/spec'; export * from './TSStringKeyword/spec'; diff --git a/packages/ast-spec/src/unions/Node.ts b/packages/ast-spec/src/unions/Node.ts index fe3435596a98..75d29c0b003d 100644 --- a/packages/ast-spec/src/unions/Node.ts +++ b/packages/ast-spec/src/unions/Node.ts @@ -141,7 +141,6 @@ import type { TSNullKeyword } from '../type/TSNullKeyword/spec'; import type { TSNumberKeyword } from '../type/TSNumberKeyword/spec'; import type { TSObjectKeyword } from '../type/TSObjectKeyword/spec'; import type { TSOptionalType } from '../type/TSOptionalType/spec'; -import type { TSParenthesizedType } from '../type/TSParenthesizedType/spec'; import type { TSQualifiedName } from '../type/TSQualifiedName/spec'; import type { TSRestType } from '../type/TSRestType/spec'; import type { TSStringKeyword } from '../type/TSStringKeyword/spec'; @@ -291,7 +290,6 @@ export type Node = | TSObjectKeyword | TSOptionalType | TSParameterProperty - | TSParenthesizedType | TSPrivateKeyword | TSPropertySignature | TSProtectedKeyword diff --git a/packages/ast-spec/src/unions/TypeNode.ts b/packages/ast-spec/src/unions/TypeNode.ts index c50630e6cd6a..55436b7a44d4 100644 --- a/packages/ast-spec/src/unions/TypeNode.ts +++ b/packages/ast-spec/src/unions/TypeNode.ts @@ -18,7 +18,6 @@ import type { TSNullKeyword } from '../type/TSNullKeyword/spec'; import type { TSNumberKeyword } from '../type/TSNumberKeyword/spec'; import type { TSObjectKeyword } from '../type/TSObjectKeyword/spec'; import type { TSOptionalType } from '../type/TSOptionalType/spec'; -import type { TSParenthesizedType } from '../type/TSParenthesizedType/spec'; import type { TSRestType } from '../type/TSRestType/spec'; import type { TSStringKeyword } from '../type/TSStringKeyword/spec'; import type { TSSymbolKeyword } from '../type/TSSymbolKeyword/spec'; @@ -56,7 +55,6 @@ export type TypeNode = | TSNumberKeyword | TSObjectKeyword | TSOptionalType - | TSParenthesizedType | TSRestType | TSStringKeyword | TSSymbolKeyword diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index 8c97729623a7..44de45f19de1 100644 --- a/packages/eslint-plugin/src/rules/array-type.ts +++ b/packages/eslint-plugin/src/rules/array-type.ts @@ -132,13 +132,8 @@ export default util.createRule({ * @param node the node to be evaluated. */ function getMessageType(node: TSESTree.Node): string { - if (node) { - if (node.type === AST_NODE_TYPES.TSParenthesizedType) { - return getMessageType(node.typeAnnotation); - } - if (isSimpleType(node)) { - return sourceCode.getText(node); - } + if (node && isSimpleType(node)) { + return sourceCode.getText(node); } return 'T'; } @@ -172,11 +167,7 @@ export default util.createRule({ type: getMessageType(node.elementType), }, fix(fixer) { - const typeNode = - node.elementType.type === AST_NODE_TYPES.TSParenthesizedType - ? node.elementType.typeAnnotation - : node.elementType; - + const typeNode = node.elementType; const arrayType = isReadonly ? 'ReadonlyArray' : 'Array'; return [ @@ -244,9 +235,12 @@ export default util.createRule({ } const type = typeParams[0]; - const typeParens = typeNeedsParentheses(type); + const typeParens = + !util.isParenthesized(type, sourceCode) && typeNeedsParentheses(type); const parentParens = - readonlyPrefix && node.parent?.type === AST_NODE_TYPES.TSArrayType; + readonlyPrefix && + node.parent?.type === AST_NODE_TYPES.TSArrayType && + !util.isParenthesized(node.parent.elementType, sourceCode); const start = `${parentParens ? '(' : ''}${readonlyPrefix}${ typeParens ? '(' : '' diff --git a/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts b/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts index 7b6bf6d35b99..f321ceff5a64 100644 --- a/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts +++ b/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts @@ -162,7 +162,6 @@ const KNOWN_NODES = new Set([ AST_NODE_TYPES.TSModuleDeclaration, AST_NODE_TYPES.TSNonNullExpression, AST_NODE_TYPES.TSParameterProperty, - AST_NODE_TYPES.TSParenthesizedType, 'TSPlusToken', AST_NODE_TYPES.TSPropertySignature, AST_NODE_TYPES.TSQualifiedName, diff --git a/packages/eslint-plugin/src/rules/indent.ts b/packages/eslint-plugin/src/rules/indent.ts index 9ac6a1593d9c..467b706004ab 100644 --- a/packages/eslint-plugin/src/rules/indent.ts +++ b/packages/eslint-plugin/src/rules/indent.ts @@ -65,7 +65,6 @@ const KNOWN_NODES = new Set([ AST_NODE_TYPES.TSModuleDeclaration, AST_NODE_TYPES.TSNonNullExpression, AST_NODE_TYPES.TSParameterProperty, - AST_NODE_TYPES.TSParenthesizedType, 'TSPlusToken', AST_NODE_TYPES.TSPropertySignature, AST_NODE_TYPES.TSQualifiedName, diff --git a/packages/eslint-plugin/src/rules/no-extra-parens.ts b/packages/eslint-plugin/src/rules/no-extra-parens.ts index 948f12ad8546..d6c6bebb25e6 100644 --- a/packages/eslint-plugin/src/rules/no-extra-parens.ts +++ b/packages/eslint-plugin/src/rules/no-extra-parens.ts @@ -81,9 +81,7 @@ export default util.createRule({ if ( node.arguments.length === 1 && node.typeParameters?.params.some( - param => - param.type === AST_NODE_TYPES.TSParenthesizedType || - param.type === AST_NODE_TYPES.TSImportType, + param => param.type === AST_NODE_TYPES.TSImportType, ) ) { return rule({ diff --git a/packages/eslint-plugin/src/rules/no-type-alias.ts b/packages/eslint-plugin/src/rules/no-type-alias.ts index 9b80efdd9d64..b5fcec64eeb6 100644 --- a/packages/eslint-plugin/src/rules/no-type-alias.ts +++ b/packages/eslint-plugin/src/rules/no-type-alias.ts @@ -293,9 +293,6 @@ export default util.createRule({ return acc; }, []); } - if (node.type === AST_NODE_TYPES.TSParenthesizedType) { - return getTypes(node.typeAnnotation, compositionType); - } return [{ node, compositionType }]; } diff --git a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts index af80720c2904..07fa42d35008 100644 --- a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts +++ b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts @@ -23,9 +23,6 @@ enum Group { function getGroup(node: TSESTree.TypeNode): Group { switch (node.type) { - case AST_NODE_TYPES.TSParenthesizedType: - return getGroup(node.typeAnnotation); - case AST_NODE_TYPES.TSConditionalType: return Group.conditional; @@ -91,6 +88,10 @@ function getGroup(node: TSESTree.TypeNode): Group { } } +function requiresParentheses(node: TSESTree.TypeNode): boolean { + return node.type === AST_NODE_TYPES.TSFunctionType; +} + export type Options = [ { checkIntersections?: boolean; @@ -211,7 +212,7 @@ export default util.createRule({ const fix: TSESLint.ReportFixFunction = fixer => { const sorted = expectedOrder - .map(t => t.text) + .map(t => (requiresParentheses(t.node) ? `(${t.text})` : t.text)) .join( node.type === AST_NODE_TYPES.TSIntersectionType ? ' & ' : ' | ', ); diff --git a/packages/eslint-plugin/tests/rules/indent/indent.test.ts b/packages/eslint-plugin/tests/rules/indent/indent.test.ts index 8296bf19520c..f5c87316c171 100644 --- a/packages/eslint-plugin/tests/rules/indent/indent.test.ts +++ b/packages/eslint-plugin/tests/rules/indent/indent.test.ts @@ -451,29 +451,6 @@ class Foo { `, ], }, - { - node: AST_NODE_TYPES.TSParenthesizedType, - code: [ - ` -const x: Array<( - | { - __typename: "Foo", - } - | { - __typename: "Baz", - } - | ( - | { - __typename: "Baz", - } - | { - __typename: "Buzz", - } - ) -)>; - `, - ], - }, // TSPlusToken - tested in TSMappedType { node: AST_NODE_TYPES.TSPropertySignature, diff --git a/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts b/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts index d0868e8293de..5f5dc37896fa 100644 --- a/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts +++ b/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts @@ -28,7 +28,7 @@ for (a in b, c); for (a in b); a(1); new a(1); -a<(A)>(1); +a(1); `, }), ...batchedSingleLineTests({ diff --git a/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts b/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts index 7dda416d6b3d..a0cf2d71dd59 100644 --- a/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts +++ b/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts @@ -127,7 +127,7 @@ const invalid = ( }, { code: noFormat`type T = (B) ${operator} (A);`, - output: noFormat`type T = (A) ${operator} (B);`, + output: noFormat`type T = A ${operator} B;`, errors: [ { messageId: 'notSortedNamed', diff --git a/packages/experimental-utils/src/ts-eslint/Rule.ts b/packages/experimental-utils/src/ts-eslint/Rule.ts index 19f457201ef1..88395def3cd0 100644 --- a/packages/experimental-utils/src/ts-eslint/Rule.ts +++ b/packages/experimental-utils/src/ts-eslint/Rule.ts @@ -379,7 +379,6 @@ interface RuleListener { TSObjectKeyword?: RuleFunction; TSOptionalType?: RuleFunction; TSParameterProperty?: RuleFunction; - TSParenthesizedType?: RuleFunction; TSPrivateKeyword?: RuleFunction; TSPropertySignature?: RuleFunction; TSProtectedKeyword?: RuleFunction; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index aad29f9b1467..e0adabf9917f 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2628,10 +2628,7 @@ export class Converter { // TypeScript specific types case SyntaxKind.ParenthesizedType: { - return this.createNode(node, { - type: AST_NODE_TYPES.TSParenthesizedType, - typeAnnotation: this.convertType(node.type), - }); + return this.convertType(node.type); } case SyntaxKind.UnionType: { return this.createNode(node, { diff --git a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts index 92ef8c42e604..a54ee9f7f765 100644 --- a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts +++ b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts @@ -188,7 +188,6 @@ export interface EstreeToTsNodeTypes { [AST_NODE_TYPES.TSNonNullExpression]: ts.NonNullExpression; [AST_NODE_TYPES.TSOptionalType]: ts.OptionalTypeNode; [AST_NODE_TYPES.TSParameterProperty]: ts.ParameterDeclaration; - [AST_NODE_TYPES.TSParenthesizedType]: ts.ParenthesizedTypeNode; [AST_NODE_TYPES.TSPropertySignature]: ts.PropertySignature; [AST_NODE_TYPES.TSQualifiedName]: ts.QualifiedName; [AST_NODE_TYPES.TSRestType]: diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index 99956cb694f0..d32e8a5766c6 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -241,6 +241,16 @@ export function preprocessBabylonAST(ast: BabelTypes.File): any { } } }, + /** + * Remove TSParenthesizedType from babel AST. Babel 8 will stop generating the TSParenthesizedType. + * Once we use babel 8, this can be removed. + * @see https://github.com/babel/babel/pull/12608 + */ + TSParenthesizedType(node: any) { + const { typeAnnotation } = node; + Object.keys(node).forEach(key => delete node[key]); + Object.assign(node, typeAnnotation); + }, }, ); } diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer-nested.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer-nested.src.ts.shot index 3c06676714fb..50f8f0f7ff82 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer-nested.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer-nested.src.ts.shot @@ -78,38 +78,33 @@ Object { "elementType": Object { "loc": Object { "end": Object { - "column": 21, + "column": 20, "line": 2, }, "start": Object { - "column": 12, + "column": 13, "line": 2, }, }, "range": Array [ - 31, - 40, + 32, + 39, ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { + "type": "TSInferType", + "typeParameter": Object { + "constraint": undefined, + "default": undefined, "loc": Object { "end": Object { "column": 20, "line": 2, }, "start": Object { - "column": 13, + "column": 19, "line": 2, }, }, - "range": Array [ - 32, - 39, - ], - "type": "TSInferType", - "typeParameter": Object { - "constraint": undefined, - "default": undefined, + "name": Object { "loc": Object { "end": Object { "column": 20, @@ -120,30 +115,18 @@ Object { "line": 2, }, }, - "name": Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "name": "U", - "range": Array [ - 38, - 39, - ], - "type": "Identifier", - }, + "name": "U", "range": Array [ 38, 39, ], - "type": "TSTypeParameter", + "type": "Identifier", }, + "range": Array [ + 38, + 39, + ], + "type": "TSTypeParameter", }, }, "loc": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer.src.ts.shot index 9054692bd03d..d55b6ac728e0 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer.src.ts.shot @@ -78,38 +78,33 @@ Object { "elementType": Object { "loc": Object { "end": Object { - "column": 37, + "column": 36, "line": 1, }, "start": Object { - "column": 28, + "column": 29, "line": 1, }, }, "range": Array [ - 28, - 37, + 29, + 36, ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { + "type": "TSInferType", + "typeParameter": Object { + "constraint": undefined, + "default": undefined, "loc": Object { "end": Object { "column": 36, "line": 1, }, "start": Object { - "column": 29, + "column": 35, "line": 1, }, }, - "range": Array [ - 29, - 36, - ], - "type": "TSInferType", - "typeParameter": Object { - "constraint": undefined, - "default": undefined, + "name": Object { "loc": Object { "end": Object { "column": 36, @@ -120,30 +115,18 @@ Object { "line": 1, }, }, - "name": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, - }, - "name": "U", - "range": Array [ - 35, - 36, - ], - "type": "Identifier", - }, + "name": "U", "range": Array [ 35, 36, ], - "type": "TSTypeParameter", + "type": "Identifier", }, + "range": Array [ + 35, + 36, + ], + "type": "TSTypeParameter", }, }, "loc": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/parenthesized-type.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/parenthesized-type.src.ts.shot index 7aa5ec4571d3..e029fb995167 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/parenthesized-type.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/parenthesized-type.src.ts.shot @@ -40,72 +40,55 @@ Object { "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 28, + "column": 27, "line": 1, }, "start": Object { - "column": 11, + "column": 12, "line": 1, }, }, "range": Array [ - 11, - 28, + 12, + 27, ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, }, + "range": Array [ + 12, + 18, + ], + "type": "TSStringKeyword", }, - "range": Array [ - 12, - 27, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, }, - "range": Array [ - 12, - 18, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 21, - "line": 1, - }, + "start": Object { + "column": 21, + "line": 1, }, - "range": Array [ - 21, - 27, - ], - "type": "TSNumberKeyword", }, - ], - }, + "range": Array [ + 21, + 27, + ], + "type": "TSNumberKeyword", + }, + ], }, }, ], diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/tuple-named-optional.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/tuple-named-optional.src.ts.shot index f07915f0394f..87f7351cba2a 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/tuple-named-optional.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/tuple-named-optional.src.ts.shot @@ -151,72 +151,55 @@ Object { "elementType": Object { "loc": Object { "end": Object { - "column": 52, + "column": 51, "line": 1, }, "start": Object { - "column": 35, + "column": 36, "line": 1, }, }, "range": Array [ - 35, - 52, + 36, + 51, ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 51, - "line": 1, - }, - "start": Object { - "column": 36, - "line": 1, + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, }, + "range": Array [ + 36, + 42, + ], + "type": "TSStringKeyword", }, - "range": Array [ - 36, - 51, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 42, - "line": 1, - }, - "start": Object { - "column": 36, - "line": 1, - }, + Object { + "loc": Object { + "end": Object { + "column": 51, + "line": 1, }, - "range": Array [ - 36, - 42, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 51, - "line": 1, - }, - "start": Object { - "column": 45, - "line": 1, - }, + "start": Object { + "column": 45, + "line": 1, }, - "range": Array [ - 45, - 51, - ], - "type": "TSNumberKeyword", }, - ], - }, + "range": Array [ + 45, + 51, + ], + "type": "TSNumberKeyword", + }, + ], }, "label": Object { "loc": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/tuple-optional.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/tuple-optional.src.ts.shot index 55be898e6a54..b359d09d8895 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/tuple-optional.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/tuple-optional.src.ts.shot @@ -111,72 +111,55 @@ Object { "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 42, + "column": 41, "line": 1, }, "start": Object { - "column": 25, + "column": 26, "line": 1, }, }, "range": Array [ - 25, - 42, + 26, + 41, ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 41, - "line": 1, - }, - "start": Object { - "column": 26, - "line": 1, + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, }, + "range": Array [ + 26, + 32, + ], + "type": "TSStringKeyword", }, - "range": Array [ - 26, - 41, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 32, - "line": 1, - }, - "start": Object { - "column": 26, - "line": 1, - }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 1, }, - "range": Array [ - 26, - 32, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 41, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, + "start": Object { + "column": 35, + "line": 1, }, - "range": Array [ - 35, - 41, - ], - "type": "TSNumberKeyword", }, - ], - }, + "range": Array [ + 35, + 41, + ], + "type": "TSNumberKeyword", + }, + ], }, }, ], diff --git a/packages/visitor-keys/src/visitor-keys.ts b/packages/visitor-keys/src/visitor-keys.ts index 1f2363e948ec..79979ba1d905 100644 --- a/packages/visitor-keys/src/visitor-keys.ts +++ b/packages/visitor-keys/src/visitor-keys.ts @@ -114,7 +114,6 @@ const additionalKeys: AdditionalKeys = { TSObjectKeyword: [], TSOptionalType: ['typeAnnotation'], TSParameterProperty: ['decorators', 'parameter'], - TSParenthesizedType: ['typeAnnotation'], TSPrivateKeyword: [], TSPropertySignature: ['typeAnnotation', 'key', 'initializer'], TSProtectedKeyword: [], pFad - Phonifier reborn

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

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


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy