From ba9dcd0fd8c738101503b7f6cbae483e2c440096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 30 Jan 2023 14:48:21 +0100 Subject: [PATCH 1/3] [ts] Support `const` modifier in type parameters --- .../src/plugins/typescript/index.ts | 202 ++--- packages/babel-parser/src/types.d.ts | 1 + .../const-type-parameters-babel-7/input.ts | 24 + .../options.json | 3 + .../const-type-parameters-babel-7/output.json | 640 +++++++++++++++ .../input.ts | 1 + .../options.json | 3 + .../output.json | 42 + .../const-type-parameters-invalid/input.ts | 1 + .../options.json | 3 + .../const-type-parameters-invalid/output.json | 46 ++ .../types/const-type-parameters/input.ts | 24 + .../types/const-type-parameters/options.json | 3 + .../types/const-type-parameters/output.json | 732 ++++++++++++++++++ .../src/ast-types/generated/index.ts | 1 + .../babel-types/src/definitions/typescript.ts | 4 + 16 files changed, 1643 insertions(+), 87 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/input.ts create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/options.json create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/output.json create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/input.ts create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/options.json create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/output.json create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/input.ts create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/options.json create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/output.json create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/input.ts create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/options.json create mode 100644 packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/output.json diff --git a/packages/babel-parser/src/plugins/typescript/index.ts b/packages/babel-parser/src/plugins/typescript/index.ts index 3a58d9d23156..db6cef17f41c 100644 --- a/packages/babel-parser/src/plugins/typescript/index.ts +++ b/packages/babel-parser/src/plugins/typescript/index.ts @@ -53,6 +53,7 @@ type TsModifier = | "declare" | "static" | "override" + | "const" | N.Accessibility | N.VarianceAnnotations; @@ -325,7 +326,11 @@ export default (superClass: ClassWithMixin) => allowedModifiers: T[], stopOnStartOfClassStaticBlock?: boolean, ): T | undefined | null { - if (!tokenIsIdentifier(this.state.type) && this.state.type !== tt._in) { + if ( + !tokenIsIdentifier(this.state.type) && + this.state.type !== tt._in && + this.state.type !== tt._const + ) { return undefined; } @@ -346,20 +351,20 @@ export default (superClass: ClassWithMixin) => * this.tsParseModifiers({ modified: node, allowedModifiers: ["public"] }); * this.tsParseModifiers({ modified: node, allowedModifiers: ["abstract", "readonly"] }); */ - tsParseModifiers({ - modified, - allowedModifiers, - disallowedModifiers, - stopOnStartOfClassStaticBlock, - errorTemplate = TSErrors.InvalidModifierOnTypeMember, - }: { - modified: ModifierBase; - allowedModifiers: readonly TsModifier[]; - disallowedModifiers?: TsModifier[]; - stopOnStartOfClassStaticBlock?: boolean; - // FIXME: make sure errorTemplate can receive `modifier` - errorTemplate?: any; - }): void { + tsParseModifiers( + { + allowedModifiers, + disallowedModifiers, + stopOnStartOfClassStaticBlock, + errorTemplate = TSErrors.InvalidModifierOnTypeMember, + }: { + allowedModifiers: readonly TsModifier[]; + disallowedModifiers?: TsModifier[]; + stopOnStartOfClassStaticBlock?: boolean; + errorTemplate?: typeof TSErrors.InvalidModifierOnTypeMember; + }, + modified: N, + ): void { const enforceOrder = ( loc: Position, modifier: TsModifier, @@ -645,37 +650,44 @@ export default (superClass: ClassWithMixin) => return this.finishNode(node, "TSTypeQuery"); } - tsParseInOutModifiers(node: N.TsTypeParameter) { - this.tsParseModifiers({ - modified: node, - allowedModifiers: ["in", "out"], - disallowedModifiers: [ - "public", - "private", - "protected", - "readonly", - "declare", - "abstract", - "override", - ], - errorTemplate: TSErrors.InvalidModifierOnTypeParameter, - }); - } - - // for better error recover - tsParseNoneModifiers(node: N.TsTypeParameter) { - this.tsParseModifiers({ - modified: node, - allowedModifiers: [], - disallowedModifiers: ["in", "out"], - errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions, - }); - } + tsParseInOutModifiers = this.tsParseModifiers.bind(this, { + allowedModifiers: ["in", "out"], + disallowedModifiers: [ + "const", + "public", + "private", + "protected", + "readonly", + "declare", + "abstract", + "override", + ], + errorTemplate: TSErrors.InvalidModifierOnTypeParameter, + }); + + tsParseConstModifier = this.tsParseModifiers.bind(this, { + allowedModifiers: ["const"], + // for better error recover + disallowedModifiers: ["in", "out"], + errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions, + }); + + tsParseInOutConstModifiers = this.tsParseModifiers.bind(this, { + allowedModifiers: ["in", "out", "const"], + disallowedModifiers: [ + "public", + "private", + "protected", + "readonly", + "declare", + "abstract", + "override", + ], + errorTemplate: TSErrors.InvalidModifierOnTypeParameter, + }); tsParseTypeParameter( - parseModifiers: ( - node: Undone, - ) => void = this.tsParseNoneModifiers.bind(this), + parseModifiers: (node: Undone) => void, ): N.TsTypeParameter { const node = this.startNode(); @@ -688,16 +700,14 @@ export default (superClass: ClassWithMixin) => } tsTryParseTypeParameters( - parseModifiers?: ((node: N.TsTypeParameter) => void) | null, + parseModifiers: (node: N.TsTypeParameter) => void, ): N.TsTypeParameterDeclaration | undefined | null { if (this.match(tt.lt)) { return this.tsParseTypeParameters(parseModifiers); } } - tsParseTypeParameters( - parseModifiers?: ((node: N.TsTypeParameter) => void) | null, - ) { + tsParseTypeParameters(parseModifiers: (node: N.TsTypeParameter) => void) { const node = this.startNode(); if (this.match(tt.lt) || this.match(tt.jsxTagStart)) { @@ -740,7 +750,9 @@ export default (superClass: ClassWithMixin) => ? "returnType" : "typeAnnotation"; - signature.typeParameters = this.tsTryParseTypeParameters(); + signature.typeParameters = this.tsTryParseTypeParameters( + this.tsParseConstModifier, + ); this.expect(tt.parenL); signature[paramsKey] = this.tsParseBindingListForSignature(); if (returnTokenRequired) { @@ -927,19 +939,21 @@ export default (superClass: ClassWithMixin) => } } - this.tsParseModifiers({ - modified: node, - allowedModifiers: ["readonly"], - disallowedModifiers: [ - "declare", - "abstract", - "private", - "protected", - "public", - "static", - "override", - ], - }); + this.tsParseModifiers( + { + allowedModifiers: ["readonly"], + disallowedModifiers: [ + "declare", + "abstract", + "private", + "protected", + "public", + "static", + "override", + ], + }, + node, + ); const idx = this.tsTryParseIndexSignature(node); if (idx) { @@ -1704,7 +1718,7 @@ export default (superClass: ClassWithMixin) => } node.typeParameters = this.tsTryParseTypeParameters( - this.tsParseInOutModifiers.bind(this), + this.tsParseInOutConstModifiers, ); if (this.eat(tt._extends)) { node.extends = this.tsParseHeritageClause("extends"); @@ -1723,7 +1737,7 @@ export default (superClass: ClassWithMixin) => node.typeAnnotation = this.tsInType(() => { node.typeParameters = this.tsTryParseTypeParameters( - this.tsParseInOutModifiers.bind(this), + this.tsParseInOutModifiers, ); this.expect(tt.eq); @@ -2191,7 +2205,9 @@ export default (superClass: ClassWithMixin) => const res: Undone | undefined | null = this.tsTryParseAndCatch(() => { const node = this.startNodeAt(startLoc); - node.typeParameters = this.tsParseTypeParameters(); + node.typeParameters = this.tsParseTypeParameters( + this.tsParseConstModifier, + ); // Don't use overloaded parseFunctionParams which would look for "<" again. super.parseFunctionParams(node); node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation(); @@ -2261,16 +2277,18 @@ export default (superClass: ClassWithMixin) => const startLoc = this.state.startLoc; const modified: ModifierBase = {}; - this.tsParseModifiers({ + this.tsParseModifiers( + { + allowedModifiers: [ + "public", + "private", + "protected", + "override", + "readonly", + ], + }, modified, - allowedModifiers: [ - "public", - "private", - "protected", - "override", - "readonly", - ], - }); + ); const accessibility = modified.accessibility; const override = modified.override; const readonly = modified.readonly; @@ -2874,13 +2892,15 @@ export default (superClass: ClassWithMixin) => "readonly", "static", ] as const; - this.tsParseModifiers({ - modified: member, - allowedModifiers: modifiers, - disallowedModifiers: ["in", "out"], - stopOnStartOfClassStaticBlock: true, - errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions, - }); + this.tsParseModifiers( + { + allowedModifiers: modifiers, + disallowedModifiers: ["in", "out"], + stopOnStartOfClassStaticBlock: true, + errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions, + }, + member, + ); const callParseClassMemberWithIsStatic = () => { if (this.tsIsStartOfStaticBlocks()) { @@ -3126,7 +3146,7 @@ export default (superClass: ClassWithMixin) => (node as any).declare ? BIND_TS_AMBIENT : BIND_CLASS, ); const typeParameters = this.tsTryParseTypeParameters( - this.tsParseInOutModifiers.bind(this), + this.tsParseInOutConstModifiers, ); if (typeParameters) node.typeParameters = typeParameters; } @@ -3211,7 +3231,9 @@ export default (superClass: ClassWithMixin) => isConstructor: boolean, allowsDirectSuper: boolean, ): void { - const typeParameters = this.tsTryParseTypeParameters(); + const typeParameters = this.tsTryParseTypeParameters( + this.tsParseConstModifier, + ); if (typeParameters && isConstructor) { this.raise(TSErrors.ConstructorHasTypeParameters, { at: typeParameters, @@ -3241,7 +3263,9 @@ export default (superClass: ClassWithMixin) => isGenerator: boolean, isAsync: boolean, ): void { - const typeParameters = this.tsTryParseTypeParameters(); + const typeParameters = this.tsTryParseTypeParameters( + this.tsParseConstModifier, + ); if (typeParameters) method.typeParameters = typeParameters; super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync); } @@ -3278,7 +3302,9 @@ export default (superClass: ClassWithMixin) => isAccessor: boolean, refExpressionErrors?: ExpressionErrors | null, ) { - const typeParameters = this.tsTryParseTypeParameters(); + const typeParameters = this.tsTryParseTypeParameters( + this.tsParseConstModifier, + ); if (typeParameters) prop.typeParameters = typeParameters; return super.parseObjPropValue( @@ -3294,7 +3320,9 @@ export default (superClass: ClassWithMixin) => } parseFunctionParams(node: N.Function, isConstructor: boolean): void { - const typeParameters = this.tsTryParseTypeParameters(); + const typeParameters = this.tsTryParseTypeParameters( + this.tsParseConstModifier, + ); if (typeParameters) node.typeParameters = typeParameters; super.parseFunctionParams(node, isConstructor); } @@ -3381,7 +3409,7 @@ export default (superClass: ClassWithMixin) => let typeParameters: N.TsTypeParameterDeclaration | undefined | null; const arrow = this.tryParse(abort => { // This is similar to TypeScript's `tryParseParenthesizedArrowFunctionExpression`. - typeParameters = this.tsParseTypeParameters(); + typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier); const expr = super.parseMaybeAssign( refExpressionErrors, afterLeftParse, diff --git a/packages/babel-parser/src/types.d.ts b/packages/babel-parser/src/types.d.ts index 1164ac98f98d..f7bf3c1a5421 100644 --- a/packages/babel-parser/src/types.d.ts +++ b/packages/babel-parser/src/types.d.ts @@ -1053,6 +1053,7 @@ export interface TsTypeParameter extends NodeBase { name: string | Identifier; in?: boolean; out?: boolean; + const?: boolean; constraint?: TsType; default?: TsType; } diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/input.ts b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/input.ts new file mode 100644 index 000000000000..0e9aa76b39c1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/input.ts @@ -0,0 +1,24 @@ +function a() {} +function b() {} +function c() {} +declare function d(); +() => {}; +() => {}; + +class A {} +class B {} +class C {} +class D {} +class E {} + +interface I {} +interface J {} +interface K {} +interface L {} +interface M {} + +class _ { + method() {} + method() {} + method() {} +} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/options.json b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/options.json new file mode 100644 index 000000000000..29a3f0e84167 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/output.json b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/output.json new file mode 100644 index 000000000000..5347298fe4a2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/output.json @@ -0,0 +1,640 @@ +{ + "type": "File", + "start":0,"end":521,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":24,"column":1,"index":521}}, + "program": { + "type": "Program", + "start":0,"end":521,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":24,"column":1,"index":521}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "id": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":10,"index":10},"identifierName":"a"}, + "name": "a" + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":10,"end":19,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":19,"index":19}}, + "params": [ + { + "type": "TSTypeParameter", + "start":11,"end":18,"loc":{"start":{"line":1,"column":11,"index":11},"end":{"line":1,"column":18,"index":18}}, + "const": true, + "name": "T" + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":22,"end":24,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":24,"index":24}}, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start":25,"end":59,"loc":{"start":{"line":2,"column":0,"index":25},"end":{"line":2,"column":34,"index":59}}, + "id": { + "type": "Identifier", + "start":34,"end":35,"loc":{"start":{"line":2,"column":9,"index":34},"end":{"line":2,"column":10,"index":35},"identifierName":"b"}, + "name": "b" + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":35,"end":54,"loc":{"start":{"line":2,"column":10,"index":35},"end":{"line":2,"column":29,"index":54}}, + "params": [ + { + "type": "TSTypeParameter", + "start":36,"end":53,"loc":{"start":{"line":2,"column":11,"index":36},"end":{"line":2,"column":28,"index":53}}, + "const": true, + "name": "T", + "constraint": { + "type": "TSTypeReference", + "start":52,"end":53,"loc":{"start":{"line":2,"column":27,"index":52},"end":{"line":2,"column":28,"index":53}}, + "typeName": { + "type": "Identifier", + "start":52,"end":53,"loc":{"start":{"line":2,"column":27,"index":52},"end":{"line":2,"column":28,"index":53},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":57,"end":59,"loc":{"start":{"line":2,"column":32,"index":57},"end":{"line":2,"column":34,"index":59}}, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start":60,"end":87,"loc":{"start":{"line":3,"column":0,"index":60},"end":{"line":3,"column":27,"index":87}}, + "id": { + "type": "Identifier", + "start":69,"end":70,"loc":{"start":{"line":3,"column":9,"index":69},"end":{"line":3,"column":10,"index":70},"identifierName":"c"}, + "name": "c" + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":70,"end":82,"loc":{"start":{"line":3,"column":10,"index":70},"end":{"line":3,"column":22,"index":82}}, + "params": [ + { + "type": "TSTypeParameter", + "start":71,"end":72,"loc":{"start":{"line":3,"column":11,"index":71},"end":{"line":3,"column":12,"index":72}}, + "name": "T" + }, + { + "type": "TSTypeParameter", + "start":74,"end":81,"loc":{"start":{"line":3,"column":14,"index":74},"end":{"line":3,"column":21,"index":81}}, + "const": true, + "name": "U" + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":85,"end":87,"loc":{"start":{"line":3,"column":25,"index":85},"end":{"line":3,"column":27,"index":87}}, + "body": [], + "directives": [] + } + }, + { + "type": "TSDeclareFunction", + "start":88,"end":118,"loc":{"start":{"line":4,"column":0,"index":88},"end":{"line":4,"column":30,"index":118}}, + "declare": true, + "id": { + "type": "Identifier", + "start":105,"end":106,"loc":{"start":{"line":4,"column":17,"index":105},"end":{"line":4,"column":18,"index":106},"identifierName":"d"}, + "name": "d" + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":106,"end":115,"loc":{"start":{"line":4,"column":18,"index":106},"end":{"line":4,"column":27,"index":115}}, + "params": [ + { + "type": "TSTypeParameter", + "start":107,"end":114,"loc":{"start":{"line":4,"column":19,"index":107},"end":{"line":4,"column":26,"index":114}}, + "const": true, + "name": "T" + } + ] + }, + "params": [] + }, + { + "type": "ExpressionStatement", + "start":119,"end":137,"loc":{"start":{"line":5,"column":0,"index":119},"end":{"line":5,"column":18,"index":137}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":119,"end":136,"loc":{"start":{"line":5,"column":0,"index":119},"end":{"line":5,"column":17,"index":136}}, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":134,"end":136,"loc":{"start":{"line":5,"column":15,"index":134},"end":{"line":5,"column":17,"index":136}}, + "body": [], + "directives": [] + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":119,"end":128,"loc":{"start":{"line":5,"column":0,"index":119},"end":{"line":5,"column":9,"index":128}}, + "params": [ + { + "type": "TSTypeParameter", + "start":120,"end":127,"loc":{"start":{"line":5,"column":1,"index":120},"end":{"line":5,"column":8,"index":127}}, + "const": true, + "name": "T" + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start":138,"end":166,"loc":{"start":{"line":6,"column":0,"index":138},"end":{"line":6,"column":28,"index":166}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":138,"end":165,"loc":{"start":{"line":6,"column":0,"index":138},"end":{"line":6,"column":27,"index":165}}, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":163,"end":165,"loc":{"start":{"line":6,"column":25,"index":163},"end":{"line":6,"column":27,"index":165}}, + "body": [], + "directives": [] + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":138,"end":157,"loc":{"start":{"line":6,"column":0,"index":138},"end":{"line":6,"column":19,"index":157}}, + "params": [ + { + "type": "TSTypeParameter", + "start":139,"end":156,"loc":{"start":{"line":6,"column":1,"index":139},"end":{"line":6,"column":18,"index":156}}, + "const": true, + "name": "T", + "constraint": { + "type": "TSTypeReference", + "start":155,"end":156,"loc":{"start":{"line":6,"column":17,"index":155},"end":{"line":6,"column":18,"index":156}}, + "typeName": { + "type": "Identifier", + "start":155,"end":156,"loc":{"start":{"line":6,"column":17,"index":155},"end":{"line":6,"column":18,"index":156},"identifierName":"U"}, + "name": "U" + } + } + } + ] + } + } + }, + { + "type": "ClassDeclaration", + "start":168,"end":187,"loc":{"start":{"line":8,"column":0,"index":168},"end":{"line":8,"column":19,"index":187}}, + "id": { + "type": "Identifier", + "start":174,"end":175,"loc":{"start":{"line":8,"column":6,"index":174},"end":{"line":8,"column":7,"index":175},"identifierName":"A"}, + "name": "A" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":175,"end":184,"loc":{"start":{"line":8,"column":7,"index":175},"end":{"line":8,"column":16,"index":184}}, + "params": [ + { + "type": "TSTypeParameter", + "start":176,"end":183,"loc":{"start":{"line":8,"column":8,"index":176},"end":{"line":8,"column":15,"index":183}}, + "const": true, + "name": "T" + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":185,"end":187,"loc":{"start":{"line":8,"column":17,"index":185},"end":{"line":8,"column":19,"index":187}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":188,"end":217,"loc":{"start":{"line":9,"column":0,"index":188},"end":{"line":9,"column":29,"index":217}}, + "id": { + "type": "Identifier", + "start":194,"end":195,"loc":{"start":{"line":9,"column":6,"index":194},"end":{"line":9,"column":7,"index":195},"identifierName":"B"}, + "name": "B" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":195,"end":214,"loc":{"start":{"line":9,"column":7,"index":195},"end":{"line":9,"column":26,"index":214}}, + "params": [ + { + "type": "TSTypeParameter", + "start":196,"end":213,"loc":{"start":{"line":9,"column":8,"index":196},"end":{"line":9,"column":25,"index":213}}, + "const": true, + "name": "T", + "constraint": { + "type": "TSTypeReference", + "start":212,"end":213,"loc":{"start":{"line":9,"column":24,"index":212},"end":{"line":9,"column":25,"index":213}}, + "typeName": { + "type": "Identifier", + "start":212,"end":213,"loc":{"start":{"line":9,"column":24,"index":212},"end":{"line":9,"column":25,"index":213},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":215,"end":217,"loc":{"start":{"line":9,"column":27,"index":215},"end":{"line":9,"column":29,"index":217}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":218,"end":240,"loc":{"start":{"line":10,"column":0,"index":218},"end":{"line":10,"column":22,"index":240}}, + "id": { + "type": "Identifier", + "start":224,"end":225,"loc":{"start":{"line":10,"column":6,"index":224},"end":{"line":10,"column":7,"index":225},"identifierName":"C"}, + "name": "C" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":225,"end":237,"loc":{"start":{"line":10,"column":7,"index":225},"end":{"line":10,"column":19,"index":237}}, + "params": [ + { + "type": "TSTypeParameter", + "start":226,"end":227,"loc":{"start":{"line":10,"column":8,"index":226},"end":{"line":10,"column":9,"index":227}}, + "name": "T" + }, + { + "type": "TSTypeParameter", + "start":229,"end":236,"loc":{"start":{"line":10,"column":11,"index":229},"end":{"line":10,"column":18,"index":236}}, + "const": true, + "name": "U" + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":238,"end":240,"loc":{"start":{"line":10,"column":20,"index":238},"end":{"line":10,"column":22,"index":240}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":241,"end":263,"loc":{"start":{"line":11,"column":0,"index":241},"end":{"line":11,"column":22,"index":263}}, + "id": { + "type": "Identifier", + "start":247,"end":248,"loc":{"start":{"line":11,"column":6,"index":247},"end":{"line":11,"column":7,"index":248},"identifierName":"D"}, + "name": "D" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":248,"end":260,"loc":{"start":{"line":11,"column":7,"index":248},"end":{"line":11,"column":19,"index":260}}, + "params": [ + { + "type": "TSTypeParameter", + "start":249,"end":259,"loc":{"start":{"line":11,"column":8,"index":249},"end":{"line":11,"column":18,"index":259}}, + "in": true, + "const": true, + "name": "T" + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":261,"end":263,"loc":{"start":{"line":11,"column":20,"index":261},"end":{"line":11,"column":22,"index":263}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":264,"end":286,"loc":{"start":{"line":12,"column":0,"index":264},"end":{"line":12,"column":22,"index":286}}, + "id": { + "type": "Identifier", + "start":270,"end":271,"loc":{"start":{"line":12,"column":6,"index":270},"end":{"line":12,"column":7,"index":271},"identifierName":"E"}, + "name": "E" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":271,"end":283,"loc":{"start":{"line":12,"column":7,"index":271},"end":{"line":12,"column":19,"index":283}}, + "params": [ + { + "type": "TSTypeParameter", + "start":272,"end":282,"loc":{"start":{"line":12,"column":8,"index":272},"end":{"line":12,"column":18,"index":282}}, + "const": true, + "in": true, + "name": "T" + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":284,"end":286,"loc":{"start":{"line":12,"column":20,"index":284},"end":{"line":12,"column":22,"index":286}}, + "body": [] + } + }, + { + "type": "TSInterfaceDeclaration", + "start":288,"end":311,"loc":{"start":{"line":14,"column":0,"index":288},"end":{"line":14,"column":23,"index":311}}, + "id": { + "type": "Identifier", + "start":298,"end":299,"loc":{"start":{"line":14,"column":10,"index":298},"end":{"line":14,"column":11,"index":299},"identifierName":"I"}, + "name": "I" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":299,"end":308,"loc":{"start":{"line":14,"column":11,"index":299},"end":{"line":14,"column":20,"index":308}}, + "params": [ + { + "type": "TSTypeParameter", + "start":300,"end":307,"loc":{"start":{"line":14,"column":12,"index":300},"end":{"line":14,"column":19,"index":307}}, + "const": true, + "name": "T" + } + ] + }, + "body": { + "type": "TSInterfaceBody", + "start":309,"end":311,"loc":{"start":{"line":14,"column":21,"index":309},"end":{"line":14,"column":23,"index":311}}, + "body": [] + } + }, + { + "type": "TSInterfaceDeclaration", + "start":312,"end":345,"loc":{"start":{"line":15,"column":0,"index":312},"end":{"line":15,"column":33,"index":345}}, + "id": { + "type": "Identifier", + "start":322,"end":323,"loc":{"start":{"line":15,"column":10,"index":322},"end":{"line":15,"column":11,"index":323},"identifierName":"J"}, + "name": "J" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":323,"end":342,"loc":{"start":{"line":15,"column":11,"index":323},"end":{"line":15,"column":30,"index":342}}, + "params": [ + { + "type": "TSTypeParameter", + "start":324,"end":341,"loc":{"start":{"line":15,"column":12,"index":324},"end":{"line":15,"column":29,"index":341}}, + "const": true, + "name": "T", + "constraint": { + "type": "TSTypeReference", + "start":340,"end":341,"loc":{"start":{"line":15,"column":28,"index":340},"end":{"line":15,"column":29,"index":341}}, + "typeName": { + "type": "Identifier", + "start":340,"end":341,"loc":{"start":{"line":15,"column":28,"index":340},"end":{"line":15,"column":29,"index":341},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "body": { + "type": "TSInterfaceBody", + "start":343,"end":345,"loc":{"start":{"line":15,"column":31,"index":343},"end":{"line":15,"column":33,"index":345}}, + "body": [] + } + }, + { + "type": "TSInterfaceDeclaration", + "start":346,"end":372,"loc":{"start":{"line":16,"column":0,"index":346},"end":{"line":16,"column":26,"index":372}}, + "id": { + "type": "Identifier", + "start":356,"end":357,"loc":{"start":{"line":16,"column":10,"index":356},"end":{"line":16,"column":11,"index":357},"identifierName":"K"}, + "name": "K" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":357,"end":369,"loc":{"start":{"line":16,"column":11,"index":357},"end":{"line":16,"column":23,"index":369}}, + "params": [ + { + "type": "TSTypeParameter", + "start":358,"end":359,"loc":{"start":{"line":16,"column":12,"index":358},"end":{"line":16,"column":13,"index":359}}, + "name": "T" + }, + { + "type": "TSTypeParameter", + "start":361,"end":368,"loc":{"start":{"line":16,"column":15,"index":361},"end":{"line":16,"column":22,"index":368}}, + "const": true, + "name": "U" + } + ] + }, + "body": { + "type": "TSInterfaceBody", + "start":370,"end":372,"loc":{"start":{"line":16,"column":24,"index":370},"end":{"line":16,"column":26,"index":372}}, + "body": [] + } + }, + { + "type": "TSInterfaceDeclaration", + "start":373,"end":399,"loc":{"start":{"line":17,"column":0,"index":373},"end":{"line":17,"column":26,"index":399}}, + "id": { + "type": "Identifier", + "start":383,"end":384,"loc":{"start":{"line":17,"column":10,"index":383},"end":{"line":17,"column":11,"index":384},"identifierName":"L"}, + "name": "L" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":384,"end":396,"loc":{"start":{"line":17,"column":11,"index":384},"end":{"line":17,"column":23,"index":396}}, + "params": [ + { + "type": "TSTypeParameter", + "start":385,"end":395,"loc":{"start":{"line":17,"column":12,"index":385},"end":{"line":17,"column":22,"index":395}}, + "in": true, + "const": true, + "name": "T" + } + ] + }, + "body": { + "type": "TSInterfaceBody", + "start":397,"end":399,"loc":{"start":{"line":17,"column":24,"index":397},"end":{"line":17,"column":26,"index":399}}, + "body": [] + } + }, + { + "type": "TSInterfaceDeclaration", + "start":400,"end":426,"loc":{"start":{"line":18,"column":0,"index":400},"end":{"line":18,"column":26,"index":426}}, + "id": { + "type": "Identifier", + "start":410,"end":411,"loc":{"start":{"line":18,"column":10,"index":410},"end":{"line":18,"column":11,"index":411},"identifierName":"M"}, + "name": "M" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":411,"end":423,"loc":{"start":{"line":18,"column":11,"index":411},"end":{"line":18,"column":23,"index":423}}, + "params": [ + { + "type": "TSTypeParameter", + "start":412,"end":422,"loc":{"start":{"line":18,"column":12,"index":412},"end":{"line":18,"column":22,"index":422}}, + "const": true, + "in": true, + "name": "T" + } + ] + }, + "body": { + "type": "TSInterfaceBody", + "start":424,"end":426,"loc":{"start":{"line":18,"column":24,"index":424},"end":{"line":18,"column":26,"index":426}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":428,"end":521,"loc":{"start":{"line":20,"column":0,"index":428},"end":{"line":24,"column":1,"index":521}}, + "id": { + "type": "Identifier", + "start":434,"end":435,"loc":{"start":{"line":20,"column":6,"index":434},"end":{"line":20,"column":7,"index":435},"identifierName":"_"}, + "name": "_" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":436,"end":521,"loc":{"start":{"line":20,"column":8,"index":436},"end":{"line":24,"column":1,"index":521}}, + "body": [ + { + "type": "ClassMethod", + "start":440,"end":460,"loc":{"start":{"line":21,"column":2,"index":440},"end":{"line":21,"column":22,"index":460}}, + "static": false, + "key": { + "type": "Identifier", + "start":440,"end":446,"loc":{"start":{"line":21,"column":2,"index":440},"end":{"line":21,"column":8,"index":446},"identifierName":"method"}, + "name": "method" + }, + "computed": false, + "kind": "method", + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":446,"end":455,"loc":{"start":{"line":21,"column":8,"index":446},"end":{"line":21,"column":17,"index":455}}, + "params": [ + { + "type": "TSTypeParameter", + "start":447,"end":454,"loc":{"start":{"line":21,"column":9,"index":447},"end":{"line":21,"column":16,"index":454}}, + "const": true, + "name": "T" + } + ] + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":458,"end":460,"loc":{"start":{"line":21,"column":20,"index":458},"end":{"line":21,"column":22,"index":460}}, + "body": [], + "directives": [] + } + }, + { + "type": "ClassMethod", + "start":463,"end":493,"loc":{"start":{"line":22,"column":2,"index":463},"end":{"line":22,"column":32,"index":493}}, + "static": false, + "key": { + "type": "Identifier", + "start":463,"end":469,"loc":{"start":{"line":22,"column":2,"index":463},"end":{"line":22,"column":8,"index":469},"identifierName":"method"}, + "name": "method" + }, + "computed": false, + "kind": "method", + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":469,"end":488,"loc":{"start":{"line":22,"column":8,"index":469},"end":{"line":22,"column":27,"index":488}}, + "params": [ + { + "type": "TSTypeParameter", + "start":470,"end":487,"loc":{"start":{"line":22,"column":9,"index":470},"end":{"line":22,"column":26,"index":487}}, + "const": true, + "name": "T", + "constraint": { + "type": "TSTypeReference", + "start":486,"end":487,"loc":{"start":{"line":22,"column":25,"index":486},"end":{"line":22,"column":26,"index":487}}, + "typeName": { + "type": "Identifier", + "start":486,"end":487,"loc":{"start":{"line":22,"column":25,"index":486},"end":{"line":22,"column":26,"index":487},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":491,"end":493,"loc":{"start":{"line":22,"column":30,"index":491},"end":{"line":22,"column":32,"index":493}}, + "body": [], + "directives": [] + } + }, + { + "type": "ClassMethod", + "start":496,"end":519,"loc":{"start":{"line":23,"column":2,"index":496},"end":{"line":23,"column":25,"index":519}}, + "static": false, + "key": { + "type": "Identifier", + "start":496,"end":502,"loc":{"start":{"line":23,"column":2,"index":496},"end":{"line":23,"column":8,"index":502},"identifierName":"method"}, + "name": "method" + }, + "computed": false, + "kind": "method", + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":502,"end":514,"loc":{"start":{"line":23,"column":8,"index":502},"end":{"line":23,"column":20,"index":514}}, + "params": [ + { + "type": "TSTypeParameter", + "start":503,"end":504,"loc":{"start":{"line":23,"column":9,"index":503},"end":{"line":23,"column":10,"index":504}}, + "name": "T" + }, + { + "type": "TSTypeParameter", + "start":506,"end":513,"loc":{"start":{"line":23,"column":12,"index":506},"end":{"line":23,"column":19,"index":513}}, + "const": true, + "name": "U" + } + ] + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":517,"end":519,"loc":{"start":{"line":23,"column":23,"index":517},"end":{"line":23,"column":25,"index":519}}, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/input.ts b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/input.ts new file mode 100644 index 000000000000..cd3e2249f66c --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/input.ts @@ -0,0 +1 @@ +type T = {}; diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/options.json b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/options.json new file mode 100644 index 000000000000..29a3f0e84167 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/output.json b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/output.json new file mode 100644 index 000000000000..f04185519076 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid-babel-7/output.json @@ -0,0 +1,42 @@ +{ + "type": "File", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":21,"index":21}}, + "errors": [ + "SyntaxError: 'const' modifier cannot appear on a type parameter. (1:7)" + ], + "program": { + "type": "Program", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":21,"index":21}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":21,"index":21}}, + "id": { + "type": "Identifier", + "start":5,"end":6,"loc":{"start":{"line":1,"column":5,"index":5},"end":{"line":1,"column":6,"index":6},"identifierName":"T"}, + "name": "T" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":6,"end":15,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":15,"index":15}}, + "params": [ + { + "type": "TSTypeParameter", + "start":7,"end":14,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":14,"index":14}}, + "const": true, + "name": "U" + } + ] + }, + "typeAnnotation": { + "type": "TSTypeLiteral", + "start":18,"end":20,"loc":{"start":{"line":1,"column":18,"index":18},"end":{"line":1,"column":20,"index":20}}, + "members": [] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/input.ts b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/input.ts new file mode 100644 index 000000000000..cd3e2249f66c --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/input.ts @@ -0,0 +1 @@ +type T = {}; diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/options.json b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/options.json new file mode 100644 index 000000000000..cbf6d1595427 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/output.json b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/output.json new file mode 100644 index 000000000000..ec7736dbcd26 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-invalid/output.json @@ -0,0 +1,46 @@ +{ + "type": "File", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":21,"index":21}}, + "errors": [ + "SyntaxError: 'const' modifier cannot appear on a type parameter. (1:7)" + ], + "program": { + "type": "Program", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":21,"index":21}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":21,"index":21}}, + "id": { + "type": "Identifier", + "start":5,"end":6,"loc":{"start":{"line":1,"column":5,"index":5},"end":{"line":1,"column":6,"index":6},"identifierName":"T"}, + "name": "T" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":6,"end":15,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":15,"index":15}}, + "params": [ + { + "type": "TSTypeParameter", + "start":7,"end":14,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":14,"index":14}}, + "const": true, + "name": { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":14,"index":14},"identifierName":"U"}, + "name": "U" + } + } + ] + }, + "typeAnnotation": { + "type": "TSTypeLiteral", + "start":18,"end":20,"loc":{"start":{"line":1,"column":18,"index":18},"end":{"line":1,"column":20,"index":20}}, + "members": [] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/input.ts b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/input.ts new file mode 100644 index 000000000000..0e9aa76b39c1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/input.ts @@ -0,0 +1,24 @@ +function a() {} +function b() {} +function c() {} +declare function d(); +() => {}; +() => {}; + +class A {} +class B {} +class C {} +class D {} +class E {} + +interface I {} +interface J {} +interface K {} +interface L {} +interface M {} + +class _ { + method() {} + method() {} + method() {} +} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/options.json b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/options.json new file mode 100644 index 000000000000..cbf6d1595427 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/output.json b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/output.json new file mode 100644 index 000000000000..9b681fd4eec7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/output.json @@ -0,0 +1,732 @@ +{ + "type": "File", + "start":0,"end":521,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":24,"column":1,"index":521}}, + "program": { + "type": "Program", + "start":0,"end":521,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":24,"column":1,"index":521}}, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":24,"index":24}}, + "id": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9,"index":9},"end":{"line":1,"column":10,"index":10},"identifierName":"a"}, + "name": "a" + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":10,"end":19,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":19,"index":19}}, + "params": [ + { + "type": "TSTypeParameter", + "start":11,"end":18,"loc":{"start":{"line":1,"column":11,"index":11},"end":{"line":1,"column":18,"index":18}}, + "const": true, + "name": { + "type": "Identifier", + "start":17,"end":18,"loc":{"start":{"line":1,"column":17,"index":17},"end":{"line":1,"column":18,"index":18},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":22,"end":24,"loc":{"start":{"line":1,"column":22,"index":22},"end":{"line":1,"column":24,"index":24}}, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start":25,"end":59,"loc":{"start":{"line":2,"column":0,"index":25},"end":{"line":2,"column":34,"index":59}}, + "id": { + "type": "Identifier", + "start":34,"end":35,"loc":{"start":{"line":2,"column":9,"index":34},"end":{"line":2,"column":10,"index":35},"identifierName":"b"}, + "name": "b" + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":35,"end":54,"loc":{"start":{"line":2,"column":10,"index":35},"end":{"line":2,"column":29,"index":54}}, + "params": [ + { + "type": "TSTypeParameter", + "start":36,"end":53,"loc":{"start":{"line":2,"column":11,"index":36},"end":{"line":2,"column":28,"index":53}}, + "const": true, + "name": { + "type": "Identifier", + "start":42,"end":43,"loc":{"start":{"line":2,"column":17,"index":42},"end":{"line":2,"column":18,"index":43},"identifierName":"T"}, + "name": "T" + }, + "constraint": { + "type": "TSTypeReference", + "start":52,"end":53,"loc":{"start":{"line":2,"column":27,"index":52},"end":{"line":2,"column":28,"index":53}}, + "typeName": { + "type": "Identifier", + "start":52,"end":53,"loc":{"start":{"line":2,"column":27,"index":52},"end":{"line":2,"column":28,"index":53},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":57,"end":59,"loc":{"start":{"line":2,"column":32,"index":57},"end":{"line":2,"column":34,"index":59}}, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start":60,"end":87,"loc":{"start":{"line":3,"column":0,"index":60},"end":{"line":3,"column":27,"index":87}}, + "id": { + "type": "Identifier", + "start":69,"end":70,"loc":{"start":{"line":3,"column":9,"index":69},"end":{"line":3,"column":10,"index":70},"identifierName":"c"}, + "name": "c" + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":70,"end":82,"loc":{"start":{"line":3,"column":10,"index":70},"end":{"line":3,"column":22,"index":82}}, + "params": [ + { + "type": "TSTypeParameter", + "start":71,"end":72,"loc":{"start":{"line":3,"column":11,"index":71},"end":{"line":3,"column":12,"index":72}}, + "name": { + "type": "Identifier", + "start":71,"end":72,"loc":{"start":{"line":3,"column":11,"index":71},"end":{"line":3,"column":12,"index":72},"identifierName":"T"}, + "name": "T" + } + }, + { + "type": "TSTypeParameter", + "start":74,"end":81,"loc":{"start":{"line":3,"column":14,"index":74},"end":{"line":3,"column":21,"index":81}}, + "const": true, + "name": { + "type": "Identifier", + "start":80,"end":81,"loc":{"start":{"line":3,"column":20,"index":80},"end":{"line":3,"column":21,"index":81},"identifierName":"U"}, + "name": "U" + } + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":85,"end":87,"loc":{"start":{"line":3,"column":25,"index":85},"end":{"line":3,"column":27,"index":87}}, + "body": [], + "directives": [] + } + }, + { + "type": "TSDeclareFunction", + "start":88,"end":118,"loc":{"start":{"line":4,"column":0,"index":88},"end":{"line":4,"column":30,"index":118}}, + "declare": true, + "id": { + "type": "Identifier", + "start":105,"end":106,"loc":{"start":{"line":4,"column":17,"index":105},"end":{"line":4,"column":18,"index":106},"identifierName":"d"}, + "name": "d" + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":106,"end":115,"loc":{"start":{"line":4,"column":18,"index":106},"end":{"line":4,"column":27,"index":115}}, + "params": [ + { + "type": "TSTypeParameter", + "start":107,"end":114,"loc":{"start":{"line":4,"column":19,"index":107},"end":{"line":4,"column":26,"index":114}}, + "const": true, + "name": { + "type": "Identifier", + "start":113,"end":114,"loc":{"start":{"line":4,"column":25,"index":113},"end":{"line":4,"column":26,"index":114},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "params": [] + }, + { + "type": "ExpressionStatement", + "start":119,"end":137,"loc":{"start":{"line":5,"column":0,"index":119},"end":{"line":5,"column":18,"index":137}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":119,"end":136,"loc":{"start":{"line":5,"column":0,"index":119},"end":{"line":5,"column":17,"index":136}}, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":134,"end":136,"loc":{"start":{"line":5,"column":15,"index":134},"end":{"line":5,"column":17,"index":136}}, + "body": [], + "directives": [] + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":119,"end":128,"loc":{"start":{"line":5,"column":0,"index":119},"end":{"line":5,"column":9,"index":128}}, + "params": [ + { + "type": "TSTypeParameter", + "start":120,"end":127,"loc":{"start":{"line":5,"column":1,"index":120},"end":{"line":5,"column":8,"index":127}}, + "const": true, + "name": { + "type": "Identifier", + "start":126,"end":127,"loc":{"start":{"line":5,"column":7,"index":126},"end":{"line":5,"column":8,"index":127},"identifierName":"T"}, + "name": "T" + } + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start":138,"end":166,"loc":{"start":{"line":6,"column":0,"index":138},"end":{"line":6,"column":28,"index":166}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":138,"end":165,"loc":{"start":{"line":6,"column":0,"index":138},"end":{"line":6,"column":27,"index":165}}, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":163,"end":165,"loc":{"start":{"line":6,"column":25,"index":163},"end":{"line":6,"column":27,"index":165}}, + "body": [], + "directives": [] + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":138,"end":157,"loc":{"start":{"line":6,"column":0,"index":138},"end":{"line":6,"column":19,"index":157}}, + "params": [ + { + "type": "TSTypeParameter", + "start":139,"end":156,"loc":{"start":{"line":6,"column":1,"index":139},"end":{"line":6,"column":18,"index":156}}, + "const": true, + "name": { + "type": "Identifier", + "start":145,"end":146,"loc":{"start":{"line":6,"column":7,"index":145},"end":{"line":6,"column":8,"index":146},"identifierName":"T"}, + "name": "T" + }, + "constraint": { + "type": "TSTypeReference", + "start":155,"end":156,"loc":{"start":{"line":6,"column":17,"index":155},"end":{"line":6,"column":18,"index":156}}, + "typeName": { + "type": "Identifier", + "start":155,"end":156,"loc":{"start":{"line":6,"column":17,"index":155},"end":{"line":6,"column":18,"index":156},"identifierName":"U"}, + "name": "U" + } + } + } + ] + } + } + }, + { + "type": "ClassDeclaration", + "start":168,"end":187,"loc":{"start":{"line":8,"column":0,"index":168},"end":{"line":8,"column":19,"index":187}}, + "id": { + "type": "Identifier", + "start":174,"end":175,"loc":{"start":{"line":8,"column":6,"index":174},"end":{"line":8,"column":7,"index":175},"identifierName":"A"}, + "name": "A" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":175,"end":184,"loc":{"start":{"line":8,"column":7,"index":175},"end":{"line":8,"column":16,"index":184}}, + "params": [ + { + "type": "TSTypeParameter", + "start":176,"end":183,"loc":{"start":{"line":8,"column":8,"index":176},"end":{"line":8,"column":15,"index":183}}, + "const": true, + "name": { + "type": "Identifier", + "start":182,"end":183,"loc":{"start":{"line":8,"column":14,"index":182},"end":{"line":8,"column":15,"index":183},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":185,"end":187,"loc":{"start":{"line":8,"column":17,"index":185},"end":{"line":8,"column":19,"index":187}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":188,"end":217,"loc":{"start":{"line":9,"column":0,"index":188},"end":{"line":9,"column":29,"index":217}}, + "id": { + "type": "Identifier", + "start":194,"end":195,"loc":{"start":{"line":9,"column":6,"index":194},"end":{"line":9,"column":7,"index":195},"identifierName":"B"}, + "name": "B" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":195,"end":214,"loc":{"start":{"line":9,"column":7,"index":195},"end":{"line":9,"column":26,"index":214}}, + "params": [ + { + "type": "TSTypeParameter", + "start":196,"end":213,"loc":{"start":{"line":9,"column":8,"index":196},"end":{"line":9,"column":25,"index":213}}, + "const": true, + "name": { + "type": "Identifier", + "start":202,"end":203,"loc":{"start":{"line":9,"column":14,"index":202},"end":{"line":9,"column":15,"index":203},"identifierName":"T"}, + "name": "T" + }, + "constraint": { + "type": "TSTypeReference", + "start":212,"end":213,"loc":{"start":{"line":9,"column":24,"index":212},"end":{"line":9,"column":25,"index":213}}, + "typeName": { + "type": "Identifier", + "start":212,"end":213,"loc":{"start":{"line":9,"column":24,"index":212},"end":{"line":9,"column":25,"index":213},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":215,"end":217,"loc":{"start":{"line":9,"column":27,"index":215},"end":{"line":9,"column":29,"index":217}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":218,"end":240,"loc":{"start":{"line":10,"column":0,"index":218},"end":{"line":10,"column":22,"index":240}}, + "id": { + "type": "Identifier", + "start":224,"end":225,"loc":{"start":{"line":10,"column":6,"index":224},"end":{"line":10,"column":7,"index":225},"identifierName":"C"}, + "name": "C" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":225,"end":237,"loc":{"start":{"line":10,"column":7,"index":225},"end":{"line":10,"column":19,"index":237}}, + "params": [ + { + "type": "TSTypeParameter", + "start":226,"end":227,"loc":{"start":{"line":10,"column":8,"index":226},"end":{"line":10,"column":9,"index":227}}, + "name": { + "type": "Identifier", + "start":226,"end":227,"loc":{"start":{"line":10,"column":8,"index":226},"end":{"line":10,"column":9,"index":227},"identifierName":"T"}, + "name": "T" + } + }, + { + "type": "TSTypeParameter", + "start":229,"end":236,"loc":{"start":{"line":10,"column":11,"index":229},"end":{"line":10,"column":18,"index":236}}, + "const": true, + "name": { + "type": "Identifier", + "start":235,"end":236,"loc":{"start":{"line":10,"column":17,"index":235},"end":{"line":10,"column":18,"index":236},"identifierName":"U"}, + "name": "U" + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":238,"end":240,"loc":{"start":{"line":10,"column":20,"index":238},"end":{"line":10,"column":22,"index":240}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":241,"end":263,"loc":{"start":{"line":11,"column":0,"index":241},"end":{"line":11,"column":22,"index":263}}, + "id": { + "type": "Identifier", + "start":247,"end":248,"loc":{"start":{"line":11,"column":6,"index":247},"end":{"line":11,"column":7,"index":248},"identifierName":"D"}, + "name": "D" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":248,"end":260,"loc":{"start":{"line":11,"column":7,"index":248},"end":{"line":11,"column":19,"index":260}}, + "params": [ + { + "type": "TSTypeParameter", + "start":249,"end":259,"loc":{"start":{"line":11,"column":8,"index":249},"end":{"line":11,"column":18,"index":259}}, + "in": true, + "const": true, + "name": { + "type": "Identifier", + "start":258,"end":259,"loc":{"start":{"line":11,"column":17,"index":258},"end":{"line":11,"column":18,"index":259},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":261,"end":263,"loc":{"start":{"line":11,"column":20,"index":261},"end":{"line":11,"column":22,"index":263}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":264,"end":286,"loc":{"start":{"line":12,"column":0,"index":264},"end":{"line":12,"column":22,"index":286}}, + "id": { + "type": "Identifier", + "start":270,"end":271,"loc":{"start":{"line":12,"column":6,"index":270},"end":{"line":12,"column":7,"index":271},"identifierName":"E"}, + "name": "E" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":271,"end":283,"loc":{"start":{"line":12,"column":7,"index":271},"end":{"line":12,"column":19,"index":283}}, + "params": [ + { + "type": "TSTypeParameter", + "start":272,"end":282,"loc":{"start":{"line":12,"column":8,"index":272},"end":{"line":12,"column":18,"index":282}}, + "const": true, + "in": true, + "name": { + "type": "Identifier", + "start":281,"end":282,"loc":{"start":{"line":12,"column":17,"index":281},"end":{"line":12,"column":18,"index":282},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":284,"end":286,"loc":{"start":{"line":12,"column":20,"index":284},"end":{"line":12,"column":22,"index":286}}, + "body": [] + } + }, + { + "type": "TSInterfaceDeclaration", + "start":288,"end":311,"loc":{"start":{"line":14,"column":0,"index":288},"end":{"line":14,"column":23,"index":311}}, + "id": { + "type": "Identifier", + "start":298,"end":299,"loc":{"start":{"line":14,"column":10,"index":298},"end":{"line":14,"column":11,"index":299},"identifierName":"I"}, + "name": "I" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":299,"end":308,"loc":{"start":{"line":14,"column":11,"index":299},"end":{"line":14,"column":20,"index":308}}, + "params": [ + { + "type": "TSTypeParameter", + "start":300,"end":307,"loc":{"start":{"line":14,"column":12,"index":300},"end":{"line":14,"column":19,"index":307}}, + "const": true, + "name": { + "type": "Identifier", + "start":306,"end":307,"loc":{"start":{"line":14,"column":18,"index":306},"end":{"line":14,"column":19,"index":307},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "body": { + "type": "TSInterfaceBody", + "start":309,"end":311,"loc":{"start":{"line":14,"column":21,"index":309},"end":{"line":14,"column":23,"index":311}}, + "body": [] + } + }, + { + "type": "TSInterfaceDeclaration", + "start":312,"end":345,"loc":{"start":{"line":15,"column":0,"index":312},"end":{"line":15,"column":33,"index":345}}, + "id": { + "type": "Identifier", + "start":322,"end":323,"loc":{"start":{"line":15,"column":10,"index":322},"end":{"line":15,"column":11,"index":323},"identifierName":"J"}, + "name": "J" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":323,"end":342,"loc":{"start":{"line":15,"column":11,"index":323},"end":{"line":15,"column":30,"index":342}}, + "params": [ + { + "type": "TSTypeParameter", + "start":324,"end":341,"loc":{"start":{"line":15,"column":12,"index":324},"end":{"line":15,"column":29,"index":341}}, + "const": true, + "name": { + "type": "Identifier", + "start":330,"end":331,"loc":{"start":{"line":15,"column":18,"index":330},"end":{"line":15,"column":19,"index":331},"identifierName":"T"}, + "name": "T" + }, + "constraint": { + "type": "TSTypeReference", + "start":340,"end":341,"loc":{"start":{"line":15,"column":28,"index":340},"end":{"line":15,"column":29,"index":341}}, + "typeName": { + "type": "Identifier", + "start":340,"end":341,"loc":{"start":{"line":15,"column":28,"index":340},"end":{"line":15,"column":29,"index":341},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "body": { + "type": "TSInterfaceBody", + "start":343,"end":345,"loc":{"start":{"line":15,"column":31,"index":343},"end":{"line":15,"column":33,"index":345}}, + "body": [] + } + }, + { + "type": "TSInterfaceDeclaration", + "start":346,"end":372,"loc":{"start":{"line":16,"column":0,"index":346},"end":{"line":16,"column":26,"index":372}}, + "id": { + "type": "Identifier", + "start":356,"end":357,"loc":{"start":{"line":16,"column":10,"index":356},"end":{"line":16,"column":11,"index":357},"identifierName":"K"}, + "name": "K" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":357,"end":369,"loc":{"start":{"line":16,"column":11,"index":357},"end":{"line":16,"column":23,"index":369}}, + "params": [ + { + "type": "TSTypeParameter", + "start":358,"end":359,"loc":{"start":{"line":16,"column":12,"index":358},"end":{"line":16,"column":13,"index":359}}, + "name": { + "type": "Identifier", + "start":358,"end":359,"loc":{"start":{"line":16,"column":12,"index":358},"end":{"line":16,"column":13,"index":359},"identifierName":"T"}, + "name": "T" + } + }, + { + "type": "TSTypeParameter", + "start":361,"end":368,"loc":{"start":{"line":16,"column":15,"index":361},"end":{"line":16,"column":22,"index":368}}, + "const": true, + "name": { + "type": "Identifier", + "start":367,"end":368,"loc":{"start":{"line":16,"column":21,"index":367},"end":{"line":16,"column":22,"index":368},"identifierName":"U"}, + "name": "U" + } + } + ] + }, + "body": { + "type": "TSInterfaceBody", + "start":370,"end":372,"loc":{"start":{"line":16,"column":24,"index":370},"end":{"line":16,"column":26,"index":372}}, + "body": [] + } + }, + { + "type": "TSInterfaceDeclaration", + "start":373,"end":399,"loc":{"start":{"line":17,"column":0,"index":373},"end":{"line":17,"column":26,"index":399}}, + "id": { + "type": "Identifier", + "start":383,"end":384,"loc":{"start":{"line":17,"column":10,"index":383},"end":{"line":17,"column":11,"index":384},"identifierName":"L"}, + "name": "L" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":384,"end":396,"loc":{"start":{"line":17,"column":11,"index":384},"end":{"line":17,"column":23,"index":396}}, + "params": [ + { + "type": "TSTypeParameter", + "start":385,"end":395,"loc":{"start":{"line":17,"column":12,"index":385},"end":{"line":17,"column":22,"index":395}}, + "in": true, + "const": true, + "name": { + "type": "Identifier", + "start":394,"end":395,"loc":{"start":{"line":17,"column":21,"index":394},"end":{"line":17,"column":22,"index":395},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "body": { + "type": "TSInterfaceBody", + "start":397,"end":399,"loc":{"start":{"line":17,"column":24,"index":397},"end":{"line":17,"column":26,"index":399}}, + "body": [] + } + }, + { + "type": "TSInterfaceDeclaration", + "start":400,"end":426,"loc":{"start":{"line":18,"column":0,"index":400},"end":{"line":18,"column":26,"index":426}}, + "id": { + "type": "Identifier", + "start":410,"end":411,"loc":{"start":{"line":18,"column":10,"index":410},"end":{"line":18,"column":11,"index":411},"identifierName":"M"}, + "name": "M" + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":411,"end":423,"loc":{"start":{"line":18,"column":11,"index":411},"end":{"line":18,"column":23,"index":423}}, + "params": [ + { + "type": "TSTypeParameter", + "start":412,"end":422,"loc":{"start":{"line":18,"column":12,"index":412},"end":{"line":18,"column":22,"index":422}}, + "const": true, + "in": true, + "name": { + "type": "Identifier", + "start":421,"end":422,"loc":{"start":{"line":18,"column":21,"index":421},"end":{"line":18,"column":22,"index":422},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "body": { + "type": "TSInterfaceBody", + "start":424,"end":426,"loc":{"start":{"line":18,"column":24,"index":424},"end":{"line":18,"column":26,"index":426}}, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start":428,"end":521,"loc":{"start":{"line":20,"column":0,"index":428},"end":{"line":24,"column":1,"index":521}}, + "id": { + "type": "Identifier", + "start":434,"end":435,"loc":{"start":{"line":20,"column":6,"index":434},"end":{"line":20,"column":7,"index":435},"identifierName":"_"}, + "name": "_" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":436,"end":521,"loc":{"start":{"line":20,"column":8,"index":436},"end":{"line":24,"column":1,"index":521}}, + "body": [ + { + "type": "ClassMethod", + "start":440,"end":460,"loc":{"start":{"line":21,"column":2,"index":440},"end":{"line":21,"column":22,"index":460}}, + "static": false, + "key": { + "type": "Identifier", + "start":440,"end":446,"loc":{"start":{"line":21,"column":2,"index":440},"end":{"line":21,"column":8,"index":446},"identifierName":"method"}, + "name": "method" + }, + "computed": false, + "kind": "method", + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":446,"end":455,"loc":{"start":{"line":21,"column":8,"index":446},"end":{"line":21,"column":17,"index":455}}, + "params": [ + { + "type": "TSTypeParameter", + "start":447,"end":454,"loc":{"start":{"line":21,"column":9,"index":447},"end":{"line":21,"column":16,"index":454}}, + "const": true, + "name": { + "type": "Identifier", + "start":453,"end":454,"loc":{"start":{"line":21,"column":15,"index":453},"end":{"line":21,"column":16,"index":454},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":458,"end":460,"loc":{"start":{"line":21,"column":20,"index":458},"end":{"line":21,"column":22,"index":460}}, + "body": [], + "directives": [] + } + }, + { + "type": "ClassMethod", + "start":463,"end":493,"loc":{"start":{"line":22,"column":2,"index":463},"end":{"line":22,"column":32,"index":493}}, + "static": false, + "key": { + "type": "Identifier", + "start":463,"end":469,"loc":{"start":{"line":22,"column":2,"index":463},"end":{"line":22,"column":8,"index":469},"identifierName":"method"}, + "name": "method" + }, + "computed": false, + "kind": "method", + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":469,"end":488,"loc":{"start":{"line":22,"column":8,"index":469},"end":{"line":22,"column":27,"index":488}}, + "params": [ + { + "type": "TSTypeParameter", + "start":470,"end":487,"loc":{"start":{"line":22,"column":9,"index":470},"end":{"line":22,"column":26,"index":487}}, + "const": true, + "name": { + "type": "Identifier", + "start":476,"end":477,"loc":{"start":{"line":22,"column":15,"index":476},"end":{"line":22,"column":16,"index":477},"identifierName":"T"}, + "name": "T" + }, + "constraint": { + "type": "TSTypeReference", + "start":486,"end":487,"loc":{"start":{"line":22,"column":25,"index":486},"end":{"line":22,"column":26,"index":487}}, + "typeName": { + "type": "Identifier", + "start":486,"end":487,"loc":{"start":{"line":22,"column":25,"index":486},"end":{"line":22,"column":26,"index":487},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":491,"end":493,"loc":{"start":{"line":22,"column":30,"index":491},"end":{"line":22,"column":32,"index":493}}, + "body": [], + "directives": [] + } + }, + { + "type": "ClassMethod", + "start":496,"end":519,"loc":{"start":{"line":23,"column":2,"index":496},"end":{"line":23,"column":25,"index":519}}, + "static": false, + "key": { + "type": "Identifier", + "start":496,"end":502,"loc":{"start":{"line":23,"column":2,"index":496},"end":{"line":23,"column":8,"index":502},"identifierName":"method"}, + "name": "method" + }, + "computed": false, + "kind": "method", + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":502,"end":514,"loc":{"start":{"line":23,"column":8,"index":502},"end":{"line":23,"column":20,"index":514}}, + "params": [ + { + "type": "TSTypeParameter", + "start":503,"end":504,"loc":{"start":{"line":23,"column":9,"index":503},"end":{"line":23,"column":10,"index":504}}, + "name": { + "type": "Identifier", + "start":503,"end":504,"loc":{"start":{"line":23,"column":9,"index":503},"end":{"line":23,"column":10,"index":504},"identifierName":"T"}, + "name": "T" + } + }, + { + "type": "TSTypeParameter", + "start":506,"end":513,"loc":{"start":{"line":23,"column":12,"index":506},"end":{"line":23,"column":19,"index":513}}, + "const": true, + "name": { + "type": "Identifier", + "start":512,"end":513,"loc":{"start":{"line":23,"column":18,"index":512},"end":{"line":23,"column":19,"index":513},"identifierName":"U"}, + "name": "U" + } + } + ] + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":517,"end":519,"loc":{"start":{"line":23,"column":23,"index":517},"end":{"line":23,"column":25,"index":519}}, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-types/src/ast-types/generated/index.ts b/packages/babel-types/src/ast-types/generated/index.ts index 7d55b779738e..d8cc07988cdc 100644 --- a/packages/babel-types/src/ast-types/generated/index.ts +++ b/packages/babel-types/src/ast-types/generated/index.ts @@ -2076,6 +2076,7 @@ export interface TSTypeParameter extends BaseNode { constraint?: TSType | null; default?: TSType | null; name: string; + const?: boolean | null; in?: boolean | null; out?: boolean | null; } diff --git a/packages/babel-types/src/definitions/typescript.ts b/packages/babel-types/src/definitions/typescript.ts index 9475c9dd6675..1cf08c5a7eda 100644 --- a/packages/babel-types/src/definitions/typescript.ts +++ b/packages/babel-types/src/definitions/typescript.ts @@ -632,6 +632,10 @@ defineType("TSTypeParameter", { validate: assertValueType("boolean"), optional: true, }, + const: { + validate: assertValueType("boolean"), + optional: true, + }, constraint: { validate: assertNodeType("TSType"), optional: true, From 442302e7c0b6f0890e352471eba5ff01c72ea10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 7 Feb 2023 13:23:02 +0100 Subject: [PATCH 2/3] Add test for expressions --- .../src/plugins/typescript/index.ts | 2 +- .../const-type-parameters-babel-7/input.ts | 8 + .../const-type-parameters-babel-7/output.json | 445 ++++++++++++--- .../types/const-type-parameters/input.ts | 8 + .../types/const-type-parameters/output.json | 517 ++++++++++++++---- 5 files changed, 805 insertions(+), 175 deletions(-) diff --git a/packages/babel-parser/src/plugins/typescript/index.ts b/packages/babel-parser/src/plugins/typescript/index.ts index db6cef17f41c..c9b73c074d3f 100644 --- a/packages/babel-parser/src/plugins/typescript/index.ts +++ b/packages/babel-parser/src/plugins/typescript/index.ts @@ -667,7 +667,7 @@ export default (superClass: ClassWithMixin) => tsParseConstModifier = this.tsParseModifiers.bind(this, { allowedModifiers: ["const"], - // for better error recover + // for better error recovery disallowedModifiers: ["in", "out"], errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions, }); diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/input.ts b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/input.ts index 0e9aa76b39c1..8134608f85e4 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/input.ts +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/input.ts @@ -4,12 +4,20 @@ function c() {} declare function d(); () => {}; () => {}; +(function () {}); +(function () {}); +(function () {}); class A {} class B {} class C {} class D {} class E {} +(class {}); +(class {}); +(class {}); +(class {}); +(class {}); interface I {} interface J {} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/output.json b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/output.json index 5347298fe4a2..70bb5e5b0b9d 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/output.json +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters-babel-7/output.json @@ -1,9 +1,9 @@ { "type": "File", - "start":0,"end":521,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":24,"column":1,"index":521}}, + "start":0,"end":744,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":32,"column":1,"index":744}}, "program": { "type": "Program", - "start":0,"end":521,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":24,"column":1,"index":521}}, + "start":0,"end":744,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":32,"column":1,"index":744}}, "sourceType": "module", "interpreter": null, "body": [ @@ -205,21 +205,137 @@ } } }, + { + "type": "ExpressionStatement", + "start":167,"end":193,"loc":{"start":{"line":7,"column":0,"index":167},"end":{"line":7,"column":26,"index":193}}, + "expression": { + "type": "FunctionExpression", + "start":168,"end":191,"loc":{"start":{"line":7,"column":1,"index":168},"end":{"line":7,"column":24,"index":191}}, + "id": null, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":177,"end":186,"loc":{"start":{"line":7,"column":10,"index":177},"end":{"line":7,"column":19,"index":186}}, + "params": [ + { + "type": "TSTypeParameter", + "start":178,"end":185,"loc":{"start":{"line":7,"column":11,"index":178},"end":{"line":7,"column":18,"index":185}}, + "const": true, + "name": "T" + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":189,"end":191,"loc":{"start":{"line":7,"column":22,"index":189},"end":{"line":7,"column":24,"index":191}}, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 167 + } + } + }, + { + "type": "ExpressionStatement", + "start":194,"end":230,"loc":{"start":{"line":8,"column":0,"index":194},"end":{"line":8,"column":36,"index":230}}, + "expression": { + "type": "FunctionExpression", + "start":195,"end":228,"loc":{"start":{"line":8,"column":1,"index":195},"end":{"line":8,"column":34,"index":228}}, + "id": null, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":204,"end":223,"loc":{"start":{"line":8,"column":10,"index":204},"end":{"line":8,"column":29,"index":223}}, + "params": [ + { + "type": "TSTypeParameter", + "start":205,"end":222,"loc":{"start":{"line":8,"column":11,"index":205},"end":{"line":8,"column":28,"index":222}}, + "const": true, + "name": "T", + "constraint": { + "type": "TSTypeReference", + "start":221,"end":222,"loc":{"start":{"line":8,"column":27,"index":221},"end":{"line":8,"column":28,"index":222}}, + "typeName": { + "type": "Identifier", + "start":221,"end":222,"loc":{"start":{"line":8,"column":27,"index":221},"end":{"line":8,"column":28,"index":222},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":226,"end":228,"loc":{"start":{"line":8,"column":32,"index":226},"end":{"line":8,"column":34,"index":228}}, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 194 + } + } + }, + { + "type": "ExpressionStatement", + "start":231,"end":260,"loc":{"start":{"line":9,"column":0,"index":231},"end":{"line":9,"column":29,"index":260}}, + "expression": { + "type": "FunctionExpression", + "start":232,"end":258,"loc":{"start":{"line":9,"column":1,"index":232},"end":{"line":9,"column":27,"index":258}}, + "id": null, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":241,"end":253,"loc":{"start":{"line":9,"column":10,"index":241},"end":{"line":9,"column":22,"index":253}}, + "params": [ + { + "type": "TSTypeParameter", + "start":242,"end":243,"loc":{"start":{"line":9,"column":11,"index":242},"end":{"line":9,"column":12,"index":243}}, + "name": "T" + }, + { + "type": "TSTypeParameter", + "start":245,"end":252,"loc":{"start":{"line":9,"column":14,"index":245},"end":{"line":9,"column":21,"index":252}}, + "const": true, + "name": "U" + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":256,"end":258,"loc":{"start":{"line":9,"column":25,"index":256},"end":{"line":9,"column":27,"index":258}}, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 231 + } + } + }, { "type": "ClassDeclaration", - "start":168,"end":187,"loc":{"start":{"line":8,"column":0,"index":168},"end":{"line":8,"column":19,"index":187}}, + "start":262,"end":281,"loc":{"start":{"line":11,"column":0,"index":262},"end":{"line":11,"column":19,"index":281}}, "id": { "type": "Identifier", - "start":174,"end":175,"loc":{"start":{"line":8,"column":6,"index":174},"end":{"line":8,"column":7,"index":175},"identifierName":"A"}, + "start":268,"end":269,"loc":{"start":{"line":11,"column":6,"index":268},"end":{"line":11,"column":7,"index":269},"identifierName":"A"}, "name": "A" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":175,"end":184,"loc":{"start":{"line":8,"column":7,"index":175},"end":{"line":8,"column":16,"index":184}}, + "start":269,"end":278,"loc":{"start":{"line":11,"column":7,"index":269},"end":{"line":11,"column":16,"index":278}}, "params": [ { "type": "TSTypeParameter", - "start":176,"end":183,"loc":{"start":{"line":8,"column":8,"index":176},"end":{"line":8,"column":15,"index":183}}, + "start":270,"end":277,"loc":{"start":{"line":11,"column":8,"index":270},"end":{"line":11,"column":15,"index":277}}, "const": true, "name": "T" } @@ -228,33 +344,33 @@ "superClass": null, "body": { "type": "ClassBody", - "start":185,"end":187,"loc":{"start":{"line":8,"column":17,"index":185},"end":{"line":8,"column":19,"index":187}}, + "start":279,"end":281,"loc":{"start":{"line":11,"column":17,"index":279},"end":{"line":11,"column":19,"index":281}}, "body": [] } }, { "type": "ClassDeclaration", - "start":188,"end":217,"loc":{"start":{"line":9,"column":0,"index":188},"end":{"line":9,"column":29,"index":217}}, + "start":282,"end":311,"loc":{"start":{"line":12,"column":0,"index":282},"end":{"line":12,"column":29,"index":311}}, "id": { "type": "Identifier", - "start":194,"end":195,"loc":{"start":{"line":9,"column":6,"index":194},"end":{"line":9,"column":7,"index":195},"identifierName":"B"}, + "start":288,"end":289,"loc":{"start":{"line":12,"column":6,"index":288},"end":{"line":12,"column":7,"index":289},"identifierName":"B"}, "name": "B" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":195,"end":214,"loc":{"start":{"line":9,"column":7,"index":195},"end":{"line":9,"column":26,"index":214}}, + "start":289,"end":308,"loc":{"start":{"line":12,"column":7,"index":289},"end":{"line":12,"column":26,"index":308}}, "params": [ { "type": "TSTypeParameter", - "start":196,"end":213,"loc":{"start":{"line":9,"column":8,"index":196},"end":{"line":9,"column":25,"index":213}}, + "start":290,"end":307,"loc":{"start":{"line":12,"column":8,"index":290},"end":{"line":12,"column":25,"index":307}}, "const": true, "name": "T", "constraint": { "type": "TSTypeReference", - "start":212,"end":213,"loc":{"start":{"line":9,"column":24,"index":212},"end":{"line":9,"column":25,"index":213}}, + "start":306,"end":307,"loc":{"start":{"line":12,"column":24,"index":306},"end":{"line":12,"column":25,"index":307}}, "typeName": { "type": "Identifier", - "start":212,"end":213,"loc":{"start":{"line":9,"column":24,"index":212},"end":{"line":9,"column":25,"index":213},"identifierName":"U"}, + "start":306,"end":307,"loc":{"start":{"line":12,"column":24,"index":306},"end":{"line":12,"column":25,"index":307},"identifierName":"U"}, "name": "U" } } @@ -264,30 +380,30 @@ "superClass": null, "body": { "type": "ClassBody", - "start":215,"end":217,"loc":{"start":{"line":9,"column":27,"index":215},"end":{"line":9,"column":29,"index":217}}, + "start":309,"end":311,"loc":{"start":{"line":12,"column":27,"index":309},"end":{"line":12,"column":29,"index":311}}, "body": [] } }, { "type": "ClassDeclaration", - "start":218,"end":240,"loc":{"start":{"line":10,"column":0,"index":218},"end":{"line":10,"column":22,"index":240}}, + "start":312,"end":334,"loc":{"start":{"line":13,"column":0,"index":312},"end":{"line":13,"column":22,"index":334}}, "id": { "type": "Identifier", - "start":224,"end":225,"loc":{"start":{"line":10,"column":6,"index":224},"end":{"line":10,"column":7,"index":225},"identifierName":"C"}, + "start":318,"end":319,"loc":{"start":{"line":13,"column":6,"index":318},"end":{"line":13,"column":7,"index":319},"identifierName":"C"}, "name": "C" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":225,"end":237,"loc":{"start":{"line":10,"column":7,"index":225},"end":{"line":10,"column":19,"index":237}}, + "start":319,"end":331,"loc":{"start":{"line":13,"column":7,"index":319},"end":{"line":13,"column":19,"index":331}}, "params": [ { "type": "TSTypeParameter", - "start":226,"end":227,"loc":{"start":{"line":10,"column":8,"index":226},"end":{"line":10,"column":9,"index":227}}, + "start":320,"end":321,"loc":{"start":{"line":13,"column":8,"index":320},"end":{"line":13,"column":9,"index":321}}, "name": "T" }, { "type": "TSTypeParameter", - "start":229,"end":236,"loc":{"start":{"line":10,"column":11,"index":229},"end":{"line":10,"column":18,"index":236}}, + "start":323,"end":330,"loc":{"start":{"line":13,"column":11,"index":323},"end":{"line":13,"column":18,"index":330}}, "const": true, "name": "U" } @@ -296,25 +412,25 @@ "superClass": null, "body": { "type": "ClassBody", - "start":238,"end":240,"loc":{"start":{"line":10,"column":20,"index":238},"end":{"line":10,"column":22,"index":240}}, + "start":332,"end":334,"loc":{"start":{"line":13,"column":20,"index":332},"end":{"line":13,"column":22,"index":334}}, "body": [] } }, { "type": "ClassDeclaration", - "start":241,"end":263,"loc":{"start":{"line":11,"column":0,"index":241},"end":{"line":11,"column":22,"index":263}}, + "start":335,"end":357,"loc":{"start":{"line":14,"column":0,"index":335},"end":{"line":14,"column":22,"index":357}}, "id": { "type": "Identifier", - "start":247,"end":248,"loc":{"start":{"line":11,"column":6,"index":247},"end":{"line":11,"column":7,"index":248},"identifierName":"D"}, + "start":341,"end":342,"loc":{"start":{"line":14,"column":6,"index":341},"end":{"line":14,"column":7,"index":342},"identifierName":"D"}, "name": "D" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":248,"end":260,"loc":{"start":{"line":11,"column":7,"index":248},"end":{"line":11,"column":19,"index":260}}, + "start":342,"end":354,"loc":{"start":{"line":14,"column":7,"index":342},"end":{"line":14,"column":19,"index":354}}, "params": [ { "type": "TSTypeParameter", - "start":249,"end":259,"loc":{"start":{"line":11,"column":8,"index":249},"end":{"line":11,"column":18,"index":259}}, + "start":343,"end":353,"loc":{"start":{"line":14,"column":8,"index":343},"end":{"line":14,"column":18,"index":353}}, "in": true, "const": true, "name": "T" @@ -324,25 +440,25 @@ "superClass": null, "body": { "type": "ClassBody", - "start":261,"end":263,"loc":{"start":{"line":11,"column":20,"index":261},"end":{"line":11,"column":22,"index":263}}, + "start":355,"end":357,"loc":{"start":{"line":14,"column":20,"index":355},"end":{"line":14,"column":22,"index":357}}, "body": [] } }, { "type": "ClassDeclaration", - "start":264,"end":286,"loc":{"start":{"line":12,"column":0,"index":264},"end":{"line":12,"column":22,"index":286}}, + "start":358,"end":380,"loc":{"start":{"line":15,"column":0,"index":358},"end":{"line":15,"column":22,"index":380}}, "id": { "type": "Identifier", - "start":270,"end":271,"loc":{"start":{"line":12,"column":6,"index":270},"end":{"line":12,"column":7,"index":271},"identifierName":"E"}, + "start":364,"end":365,"loc":{"start":{"line":15,"column":6,"index":364},"end":{"line":15,"column":7,"index":365},"identifierName":"E"}, "name": "E" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":271,"end":283,"loc":{"start":{"line":12,"column":7,"index":271},"end":{"line":12,"column":19,"index":283}}, + "start":365,"end":377,"loc":{"start":{"line":15,"column":7,"index":365},"end":{"line":15,"column":19,"index":377}}, "params": [ { "type": "TSTypeParameter", - "start":272,"end":282,"loc":{"start":{"line":12,"column":8,"index":272},"end":{"line":12,"column":18,"index":282}}, + "start":366,"end":376,"loc":{"start":{"line":15,"column":8,"index":366},"end":{"line":15,"column":18,"index":376}}, "const": true, "in": true, "name": "T" @@ -352,25 +468,196 @@ "superClass": null, "body": { "type": "ClassBody", - "start":284,"end":286,"loc":{"start":{"line":12,"column":20,"index":284},"end":{"line":12,"column":22,"index":286}}, + "start":378,"end":380,"loc":{"start":{"line":15,"column":20,"index":378},"end":{"line":15,"column":22,"index":380}}, "body": [] } }, + { + "type": "ExpressionStatement", + "start":381,"end":402,"loc":{"start":{"line":16,"column":0,"index":381},"end":{"line":16,"column":21,"index":402}}, + "expression": { + "type": "ClassExpression", + "start":382,"end":400,"loc":{"start":{"line":16,"column":1,"index":382},"end":{"line":16,"column":19,"index":400}}, + "id": null, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":388,"end":397,"loc":{"start":{"line":16,"column":7,"index":388},"end":{"line":16,"column":16,"index":397}}, + "params": [ + { + "type": "TSTypeParameter", + "start":389,"end":396,"loc":{"start":{"line":16,"column":8,"index":389},"end":{"line":16,"column":15,"index":396}}, + "const": true, + "name": "T" + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":398,"end":400,"loc":{"start":{"line":16,"column":17,"index":398},"end":{"line":16,"column":19,"index":400}}, + "body": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 381 + } + } + }, + { + "type": "ExpressionStatement", + "start":403,"end":434,"loc":{"start":{"line":17,"column":0,"index":403},"end":{"line":17,"column":31,"index":434}}, + "expression": { + "type": "ClassExpression", + "start":404,"end":432,"loc":{"start":{"line":17,"column":1,"index":404},"end":{"line":17,"column":29,"index":432}}, + "id": null, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":410,"end":429,"loc":{"start":{"line":17,"column":7,"index":410},"end":{"line":17,"column":26,"index":429}}, + "params": [ + { + "type": "TSTypeParameter", + "start":411,"end":428,"loc":{"start":{"line":17,"column":8,"index":411},"end":{"line":17,"column":25,"index":428}}, + "const": true, + "name": "T", + "constraint": { + "type": "TSTypeReference", + "start":427,"end":428,"loc":{"start":{"line":17,"column":24,"index":427},"end":{"line":17,"column":25,"index":428}}, + "typeName": { + "type": "Identifier", + "start":427,"end":428,"loc":{"start":{"line":17,"column":24,"index":427},"end":{"line":17,"column":25,"index":428},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":430,"end":432,"loc":{"start":{"line":17,"column":27,"index":430},"end":{"line":17,"column":29,"index":432}}, + "body": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 403 + } + } + }, + { + "type": "ExpressionStatement", + "start":435,"end":459,"loc":{"start":{"line":18,"column":0,"index":435},"end":{"line":18,"column":24,"index":459}}, + "expression": { + "type": "ClassExpression", + "start":436,"end":457,"loc":{"start":{"line":18,"column":1,"index":436},"end":{"line":18,"column":22,"index":457}}, + "id": null, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":442,"end":454,"loc":{"start":{"line":18,"column":7,"index":442},"end":{"line":18,"column":19,"index":454}}, + "params": [ + { + "type": "TSTypeParameter", + "start":443,"end":444,"loc":{"start":{"line":18,"column":8,"index":443},"end":{"line":18,"column":9,"index":444}}, + "name": "T" + }, + { + "type": "TSTypeParameter", + "start":446,"end":453,"loc":{"start":{"line":18,"column":11,"index":446},"end":{"line":18,"column":18,"index":453}}, + "const": true, + "name": "U" + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":455,"end":457,"loc":{"start":{"line":18,"column":20,"index":455},"end":{"line":18,"column":22,"index":457}}, + "body": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 435 + } + } + }, + { + "type": "ExpressionStatement", + "start":460,"end":484,"loc":{"start":{"line":19,"column":0,"index":460},"end":{"line":19,"column":24,"index":484}}, + "expression": { + "type": "ClassExpression", + "start":461,"end":482,"loc":{"start":{"line":19,"column":1,"index":461},"end":{"line":19,"column":22,"index":482}}, + "id": null, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":467,"end":479,"loc":{"start":{"line":19,"column":7,"index":467},"end":{"line":19,"column":19,"index":479}}, + "params": [ + { + "type": "TSTypeParameter", + "start":468,"end":478,"loc":{"start":{"line":19,"column":8,"index":468},"end":{"line":19,"column":18,"index":478}}, + "in": true, + "const": true, + "name": "T" + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":480,"end":482,"loc":{"start":{"line":19,"column":20,"index":480},"end":{"line":19,"column":22,"index":482}}, + "body": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 460 + } + } + }, + { + "type": "ExpressionStatement", + "start":485,"end":509,"loc":{"start":{"line":20,"column":0,"index":485},"end":{"line":20,"column":24,"index":509}}, + "expression": { + "type": "ClassExpression", + "start":486,"end":507,"loc":{"start":{"line":20,"column":1,"index":486},"end":{"line":20,"column":22,"index":507}}, + "id": null, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":492,"end":504,"loc":{"start":{"line":20,"column":7,"index":492},"end":{"line":20,"column":19,"index":504}}, + "params": [ + { + "type": "TSTypeParameter", + "start":493,"end":503,"loc":{"start":{"line":20,"column":8,"index":493},"end":{"line":20,"column":18,"index":503}}, + "const": true, + "in": true, + "name": "T" + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":505,"end":507,"loc":{"start":{"line":20,"column":20,"index":505},"end":{"line":20,"column":22,"index":507}}, + "body": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 485 + } + } + }, { "type": "TSInterfaceDeclaration", - "start":288,"end":311,"loc":{"start":{"line":14,"column":0,"index":288},"end":{"line":14,"column":23,"index":311}}, + "start":511,"end":534,"loc":{"start":{"line":22,"column":0,"index":511},"end":{"line":22,"column":23,"index":534}}, "id": { "type": "Identifier", - "start":298,"end":299,"loc":{"start":{"line":14,"column":10,"index":298},"end":{"line":14,"column":11,"index":299},"identifierName":"I"}, + "start":521,"end":522,"loc":{"start":{"line":22,"column":10,"index":521},"end":{"line":22,"column":11,"index":522},"identifierName":"I"}, "name": "I" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":299,"end":308,"loc":{"start":{"line":14,"column":11,"index":299},"end":{"line":14,"column":20,"index":308}}, + "start":522,"end":531,"loc":{"start":{"line":22,"column":11,"index":522},"end":{"line":22,"column":20,"index":531}}, "params": [ { "type": "TSTypeParameter", - "start":300,"end":307,"loc":{"start":{"line":14,"column":12,"index":300},"end":{"line":14,"column":19,"index":307}}, + "start":523,"end":530,"loc":{"start":{"line":22,"column":12,"index":523},"end":{"line":22,"column":19,"index":530}}, "const": true, "name": "T" } @@ -378,33 +665,33 @@ }, "body": { "type": "TSInterfaceBody", - "start":309,"end":311,"loc":{"start":{"line":14,"column":21,"index":309},"end":{"line":14,"column":23,"index":311}}, + "start":532,"end":534,"loc":{"start":{"line":22,"column":21,"index":532},"end":{"line":22,"column":23,"index":534}}, "body": [] } }, { "type": "TSInterfaceDeclaration", - "start":312,"end":345,"loc":{"start":{"line":15,"column":0,"index":312},"end":{"line":15,"column":33,"index":345}}, + "start":535,"end":568,"loc":{"start":{"line":23,"column":0,"index":535},"end":{"line":23,"column":33,"index":568}}, "id": { "type": "Identifier", - "start":322,"end":323,"loc":{"start":{"line":15,"column":10,"index":322},"end":{"line":15,"column":11,"index":323},"identifierName":"J"}, + "start":545,"end":546,"loc":{"start":{"line":23,"column":10,"index":545},"end":{"line":23,"column":11,"index":546},"identifierName":"J"}, "name": "J" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":323,"end":342,"loc":{"start":{"line":15,"column":11,"index":323},"end":{"line":15,"column":30,"index":342}}, + "start":546,"end":565,"loc":{"start":{"line":23,"column":11,"index":546},"end":{"line":23,"column":30,"index":565}}, "params": [ { "type": "TSTypeParameter", - "start":324,"end":341,"loc":{"start":{"line":15,"column":12,"index":324},"end":{"line":15,"column":29,"index":341}}, + "start":547,"end":564,"loc":{"start":{"line":23,"column":12,"index":547},"end":{"line":23,"column":29,"index":564}}, "const": true, "name": "T", "constraint": { "type": "TSTypeReference", - "start":340,"end":341,"loc":{"start":{"line":15,"column":28,"index":340},"end":{"line":15,"column":29,"index":341}}, + "start":563,"end":564,"loc":{"start":{"line":23,"column":28,"index":563},"end":{"line":23,"column":29,"index":564}}, "typeName": { "type": "Identifier", - "start":340,"end":341,"loc":{"start":{"line":15,"column":28,"index":340},"end":{"line":15,"column":29,"index":341},"identifierName":"U"}, + "start":563,"end":564,"loc":{"start":{"line":23,"column":28,"index":563},"end":{"line":23,"column":29,"index":564},"identifierName":"U"}, "name": "U" } } @@ -413,30 +700,30 @@ }, "body": { "type": "TSInterfaceBody", - "start":343,"end":345,"loc":{"start":{"line":15,"column":31,"index":343},"end":{"line":15,"column":33,"index":345}}, + "start":566,"end":568,"loc":{"start":{"line":23,"column":31,"index":566},"end":{"line":23,"column":33,"index":568}}, "body": [] } }, { "type": "TSInterfaceDeclaration", - "start":346,"end":372,"loc":{"start":{"line":16,"column":0,"index":346},"end":{"line":16,"column":26,"index":372}}, + "start":569,"end":595,"loc":{"start":{"line":24,"column":0,"index":569},"end":{"line":24,"column":26,"index":595}}, "id": { "type": "Identifier", - "start":356,"end":357,"loc":{"start":{"line":16,"column":10,"index":356},"end":{"line":16,"column":11,"index":357},"identifierName":"K"}, + "start":579,"end":580,"loc":{"start":{"line":24,"column":10,"index":579},"end":{"line":24,"column":11,"index":580},"identifierName":"K"}, "name": "K" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":357,"end":369,"loc":{"start":{"line":16,"column":11,"index":357},"end":{"line":16,"column":23,"index":369}}, + "start":580,"end":592,"loc":{"start":{"line":24,"column":11,"index":580},"end":{"line":24,"column":23,"index":592}}, "params": [ { "type": "TSTypeParameter", - "start":358,"end":359,"loc":{"start":{"line":16,"column":12,"index":358},"end":{"line":16,"column":13,"index":359}}, + "start":581,"end":582,"loc":{"start":{"line":24,"column":12,"index":581},"end":{"line":24,"column":13,"index":582}}, "name": "T" }, { "type": "TSTypeParameter", - "start":361,"end":368,"loc":{"start":{"line":16,"column":15,"index":361},"end":{"line":16,"column":22,"index":368}}, + "start":584,"end":591,"loc":{"start":{"line":24,"column":15,"index":584},"end":{"line":24,"column":22,"index":591}}, "const": true, "name": "U" } @@ -444,25 +731,25 @@ }, "body": { "type": "TSInterfaceBody", - "start":370,"end":372,"loc":{"start":{"line":16,"column":24,"index":370},"end":{"line":16,"column":26,"index":372}}, + "start":593,"end":595,"loc":{"start":{"line":24,"column":24,"index":593},"end":{"line":24,"column":26,"index":595}}, "body": [] } }, { "type": "TSInterfaceDeclaration", - "start":373,"end":399,"loc":{"start":{"line":17,"column":0,"index":373},"end":{"line":17,"column":26,"index":399}}, + "start":596,"end":622,"loc":{"start":{"line":25,"column":0,"index":596},"end":{"line":25,"column":26,"index":622}}, "id": { "type": "Identifier", - "start":383,"end":384,"loc":{"start":{"line":17,"column":10,"index":383},"end":{"line":17,"column":11,"index":384},"identifierName":"L"}, + "start":606,"end":607,"loc":{"start":{"line":25,"column":10,"index":606},"end":{"line":25,"column":11,"index":607},"identifierName":"L"}, "name": "L" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":384,"end":396,"loc":{"start":{"line":17,"column":11,"index":384},"end":{"line":17,"column":23,"index":396}}, + "start":607,"end":619,"loc":{"start":{"line":25,"column":11,"index":607},"end":{"line":25,"column":23,"index":619}}, "params": [ { "type": "TSTypeParameter", - "start":385,"end":395,"loc":{"start":{"line":17,"column":12,"index":385},"end":{"line":17,"column":22,"index":395}}, + "start":608,"end":618,"loc":{"start":{"line":25,"column":12,"index":608},"end":{"line":25,"column":22,"index":618}}, "in": true, "const": true, "name": "T" @@ -471,25 +758,25 @@ }, "body": { "type": "TSInterfaceBody", - "start":397,"end":399,"loc":{"start":{"line":17,"column":24,"index":397},"end":{"line":17,"column":26,"index":399}}, + "start":620,"end":622,"loc":{"start":{"line":25,"column":24,"index":620},"end":{"line":25,"column":26,"index":622}}, "body": [] } }, { "type": "TSInterfaceDeclaration", - "start":400,"end":426,"loc":{"start":{"line":18,"column":0,"index":400},"end":{"line":18,"column":26,"index":426}}, + "start":623,"end":649,"loc":{"start":{"line":26,"column":0,"index":623},"end":{"line":26,"column":26,"index":649}}, "id": { "type": "Identifier", - "start":410,"end":411,"loc":{"start":{"line":18,"column":10,"index":410},"end":{"line":18,"column":11,"index":411},"identifierName":"M"}, + "start":633,"end":634,"loc":{"start":{"line":26,"column":10,"index":633},"end":{"line":26,"column":11,"index":634},"identifierName":"M"}, "name": "M" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":411,"end":423,"loc":{"start":{"line":18,"column":11,"index":411},"end":{"line":18,"column":23,"index":423}}, + "start":634,"end":646,"loc":{"start":{"line":26,"column":11,"index":634},"end":{"line":26,"column":23,"index":646}}, "params": [ { "type": "TSTypeParameter", - "start":412,"end":422,"loc":{"start":{"line":18,"column":12,"index":412},"end":{"line":18,"column":22,"index":422}}, + "start":635,"end":645,"loc":{"start":{"line":26,"column":12,"index":635},"end":{"line":26,"column":22,"index":645}}, "const": true, "in": true, "name": "T" @@ -498,41 +785,41 @@ }, "body": { "type": "TSInterfaceBody", - "start":424,"end":426,"loc":{"start":{"line":18,"column":24,"index":424},"end":{"line":18,"column":26,"index":426}}, + "start":647,"end":649,"loc":{"start":{"line":26,"column":24,"index":647},"end":{"line":26,"column":26,"index":649}}, "body": [] } }, { "type": "ClassDeclaration", - "start":428,"end":521,"loc":{"start":{"line":20,"column":0,"index":428},"end":{"line":24,"column":1,"index":521}}, + "start":651,"end":744,"loc":{"start":{"line":28,"column":0,"index":651},"end":{"line":32,"column":1,"index":744}}, "id": { "type": "Identifier", - "start":434,"end":435,"loc":{"start":{"line":20,"column":6,"index":434},"end":{"line":20,"column":7,"index":435},"identifierName":"_"}, + "start":657,"end":658,"loc":{"start":{"line":28,"column":6,"index":657},"end":{"line":28,"column":7,"index":658},"identifierName":"_"}, "name": "_" }, "superClass": null, "body": { "type": "ClassBody", - "start":436,"end":521,"loc":{"start":{"line":20,"column":8,"index":436},"end":{"line":24,"column":1,"index":521}}, + "start":659,"end":744,"loc":{"start":{"line":28,"column":8,"index":659},"end":{"line":32,"column":1,"index":744}}, "body": [ { "type": "ClassMethod", - "start":440,"end":460,"loc":{"start":{"line":21,"column":2,"index":440},"end":{"line":21,"column":22,"index":460}}, + "start":663,"end":683,"loc":{"start":{"line":29,"column":2,"index":663},"end":{"line":29,"column":22,"index":683}}, "static": false, "key": { "type": "Identifier", - "start":440,"end":446,"loc":{"start":{"line":21,"column":2,"index":440},"end":{"line":21,"column":8,"index":446},"identifierName":"method"}, + "start":663,"end":669,"loc":{"start":{"line":29,"column":2,"index":663},"end":{"line":29,"column":8,"index":669},"identifierName":"method"}, "name": "method" }, "computed": false, "kind": "method", "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":446,"end":455,"loc":{"start":{"line":21,"column":8,"index":446},"end":{"line":21,"column":17,"index":455}}, + "start":669,"end":678,"loc":{"start":{"line":29,"column":8,"index":669},"end":{"line":29,"column":17,"index":678}}, "params": [ { "type": "TSTypeParameter", - "start":447,"end":454,"loc":{"start":{"line":21,"column":9,"index":447},"end":{"line":21,"column":16,"index":454}}, + "start":670,"end":677,"loc":{"start":{"line":29,"column":9,"index":670},"end":{"line":29,"column":16,"index":677}}, "const": true, "name": "T" } @@ -544,37 +831,37 @@ "params": [], "body": { "type": "BlockStatement", - "start":458,"end":460,"loc":{"start":{"line":21,"column":20,"index":458},"end":{"line":21,"column":22,"index":460}}, + "start":681,"end":683,"loc":{"start":{"line":29,"column":20,"index":681},"end":{"line":29,"column":22,"index":683}}, "body": [], "directives": [] } }, { "type": "ClassMethod", - "start":463,"end":493,"loc":{"start":{"line":22,"column":2,"index":463},"end":{"line":22,"column":32,"index":493}}, + "start":686,"end":716,"loc":{"start":{"line":30,"column":2,"index":686},"end":{"line":30,"column":32,"index":716}}, "static": false, "key": { "type": "Identifier", - "start":463,"end":469,"loc":{"start":{"line":22,"column":2,"index":463},"end":{"line":22,"column":8,"index":469},"identifierName":"method"}, + "start":686,"end":692,"loc":{"start":{"line":30,"column":2,"index":686},"end":{"line":30,"column":8,"index":692},"identifierName":"method"}, "name": "method" }, "computed": false, "kind": "method", "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":469,"end":488,"loc":{"start":{"line":22,"column":8,"index":469},"end":{"line":22,"column":27,"index":488}}, + "start":692,"end":711,"loc":{"start":{"line":30,"column":8,"index":692},"end":{"line":30,"column":27,"index":711}}, "params": [ { "type": "TSTypeParameter", - "start":470,"end":487,"loc":{"start":{"line":22,"column":9,"index":470},"end":{"line":22,"column":26,"index":487}}, + "start":693,"end":710,"loc":{"start":{"line":30,"column":9,"index":693},"end":{"line":30,"column":26,"index":710}}, "const": true, "name": "T", "constraint": { "type": "TSTypeReference", - "start":486,"end":487,"loc":{"start":{"line":22,"column":25,"index":486},"end":{"line":22,"column":26,"index":487}}, + "start":709,"end":710,"loc":{"start":{"line":30,"column":25,"index":709},"end":{"line":30,"column":26,"index":710}}, "typeName": { "type": "Identifier", - "start":486,"end":487,"loc":{"start":{"line":22,"column":25,"index":486},"end":{"line":22,"column":26,"index":487},"identifierName":"U"}, + "start":709,"end":710,"loc":{"start":{"line":30,"column":25,"index":709},"end":{"line":30,"column":26,"index":710},"identifierName":"U"}, "name": "U" } } @@ -587,34 +874,34 @@ "params": [], "body": { "type": "BlockStatement", - "start":491,"end":493,"loc":{"start":{"line":22,"column":30,"index":491},"end":{"line":22,"column":32,"index":493}}, + "start":714,"end":716,"loc":{"start":{"line":30,"column":30,"index":714},"end":{"line":30,"column":32,"index":716}}, "body": [], "directives": [] } }, { "type": "ClassMethod", - "start":496,"end":519,"loc":{"start":{"line":23,"column":2,"index":496},"end":{"line":23,"column":25,"index":519}}, + "start":719,"end":742,"loc":{"start":{"line":31,"column":2,"index":719},"end":{"line":31,"column":25,"index":742}}, "static": false, "key": { "type": "Identifier", - "start":496,"end":502,"loc":{"start":{"line":23,"column":2,"index":496},"end":{"line":23,"column":8,"index":502},"identifierName":"method"}, + "start":719,"end":725,"loc":{"start":{"line":31,"column":2,"index":719},"end":{"line":31,"column":8,"index":725},"identifierName":"method"}, "name": "method" }, "computed": false, "kind": "method", "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":502,"end":514,"loc":{"start":{"line":23,"column":8,"index":502},"end":{"line":23,"column":20,"index":514}}, + "start":725,"end":737,"loc":{"start":{"line":31,"column":8,"index":725},"end":{"line":31,"column":20,"index":737}}, "params": [ { "type": "TSTypeParameter", - "start":503,"end":504,"loc":{"start":{"line":23,"column":9,"index":503},"end":{"line":23,"column":10,"index":504}}, + "start":726,"end":727,"loc":{"start":{"line":31,"column":9,"index":726},"end":{"line":31,"column":10,"index":727}}, "name": "T" }, { "type": "TSTypeParameter", - "start":506,"end":513,"loc":{"start":{"line":23,"column":12,"index":506},"end":{"line":23,"column":19,"index":513}}, + "start":729,"end":736,"loc":{"start":{"line":31,"column":12,"index":729},"end":{"line":31,"column":19,"index":736}}, "const": true, "name": "U" } @@ -626,7 +913,7 @@ "params": [], "body": { "type": "BlockStatement", - "start":517,"end":519,"loc":{"start":{"line":23,"column":23,"index":517},"end":{"line":23,"column":25,"index":519}}, + "start":740,"end":742,"loc":{"start":{"line":31,"column":23,"index":740},"end":{"line":31,"column":25,"index":742}}, "body": [], "directives": [] } diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/input.ts b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/input.ts index 0e9aa76b39c1..8134608f85e4 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/input.ts +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/input.ts @@ -4,12 +4,20 @@ function c() {} declare function d(); () => {}; () => {}; +(function () {}); +(function () {}); +(function () {}); class A {} class B {} class C {} class D {} class E {} +(class {}); +(class {}); +(class {}); +(class {}); +(class {}); interface I {} interface J {} diff --git a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/output.json b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/output.json index 9b681fd4eec7..ba550fe8c335 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/output.json +++ b/packages/babel-parser/test/fixtures/typescript/types/const-type-parameters/output.json @@ -1,9 +1,9 @@ { "type": "File", - "start":0,"end":521,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":24,"column":1,"index":521}}, + "start":0,"end":744,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":32,"column":1,"index":744}}, "program": { "type": "Program", - "start":0,"end":521,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":24,"column":1,"index":521}}, + "start":0,"end":744,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":32,"column":1,"index":744}}, "sourceType": "module", "interpreter": null, "body": [ @@ -233,25 +233,157 @@ } } }, + { + "type": "ExpressionStatement", + "start":167,"end":193,"loc":{"start":{"line":7,"column":0,"index":167},"end":{"line":7,"column":26,"index":193}}, + "expression": { + "type": "FunctionExpression", + "start":168,"end":191,"loc":{"start":{"line":7,"column":1,"index":168},"end":{"line":7,"column":24,"index":191}}, + "id": null, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":177,"end":186,"loc":{"start":{"line":7,"column":10,"index":177},"end":{"line":7,"column":19,"index":186}}, + "params": [ + { + "type": "TSTypeParameter", + "start":178,"end":185,"loc":{"start":{"line":7,"column":11,"index":178},"end":{"line":7,"column":18,"index":185}}, + "const": true, + "name": { + "type": "Identifier", + "start":184,"end":185,"loc":{"start":{"line":7,"column":17,"index":184},"end":{"line":7,"column":18,"index":185},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":189,"end":191,"loc":{"start":{"line":7,"column":22,"index":189},"end":{"line":7,"column":24,"index":191}}, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 167 + } + } + }, + { + "type": "ExpressionStatement", + "start":194,"end":230,"loc":{"start":{"line":8,"column":0,"index":194},"end":{"line":8,"column":36,"index":230}}, + "expression": { + "type": "FunctionExpression", + "start":195,"end":228,"loc":{"start":{"line":8,"column":1,"index":195},"end":{"line":8,"column":34,"index":228}}, + "id": null, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":204,"end":223,"loc":{"start":{"line":8,"column":10,"index":204},"end":{"line":8,"column":29,"index":223}}, + "params": [ + { + "type": "TSTypeParameter", + "start":205,"end":222,"loc":{"start":{"line":8,"column":11,"index":205},"end":{"line":8,"column":28,"index":222}}, + "const": true, + "name": { + "type": "Identifier", + "start":211,"end":212,"loc":{"start":{"line":8,"column":17,"index":211},"end":{"line":8,"column":18,"index":212},"identifierName":"T"}, + "name": "T" + }, + "constraint": { + "type": "TSTypeReference", + "start":221,"end":222,"loc":{"start":{"line":8,"column":27,"index":221},"end":{"line":8,"column":28,"index":222}}, + "typeName": { + "type": "Identifier", + "start":221,"end":222,"loc":{"start":{"line":8,"column":27,"index":221},"end":{"line":8,"column":28,"index":222},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":226,"end":228,"loc":{"start":{"line":8,"column":32,"index":226},"end":{"line":8,"column":34,"index":228}}, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 194 + } + } + }, + { + "type": "ExpressionStatement", + "start":231,"end":260,"loc":{"start":{"line":9,"column":0,"index":231},"end":{"line":9,"column":29,"index":260}}, + "expression": { + "type": "FunctionExpression", + "start":232,"end":258,"loc":{"start":{"line":9,"column":1,"index":232},"end":{"line":9,"column":27,"index":258}}, + "id": null, + "generator": false, + "async": false, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":241,"end":253,"loc":{"start":{"line":9,"column":10,"index":241},"end":{"line":9,"column":22,"index":253}}, + "params": [ + { + "type": "TSTypeParameter", + "start":242,"end":243,"loc":{"start":{"line":9,"column":11,"index":242},"end":{"line":9,"column":12,"index":243}}, + "name": { + "type": "Identifier", + "start":242,"end":243,"loc":{"start":{"line":9,"column":11,"index":242},"end":{"line":9,"column":12,"index":243},"identifierName":"T"}, + "name": "T" + } + }, + { + "type": "TSTypeParameter", + "start":245,"end":252,"loc":{"start":{"line":9,"column":14,"index":245},"end":{"line":9,"column":21,"index":252}}, + "const": true, + "name": { + "type": "Identifier", + "start":251,"end":252,"loc":{"start":{"line":9,"column":20,"index":251},"end":{"line":9,"column":21,"index":252},"identifierName":"U"}, + "name": "U" + } + } + ] + }, + "params": [], + "body": { + "type": "BlockStatement", + "start":256,"end":258,"loc":{"start":{"line":9,"column":25,"index":256},"end":{"line":9,"column":27,"index":258}}, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 231 + } + } + }, { "type": "ClassDeclaration", - "start":168,"end":187,"loc":{"start":{"line":8,"column":0,"index":168},"end":{"line":8,"column":19,"index":187}}, + "start":262,"end":281,"loc":{"start":{"line":11,"column":0,"index":262},"end":{"line":11,"column":19,"index":281}}, "id": { "type": "Identifier", - "start":174,"end":175,"loc":{"start":{"line":8,"column":6,"index":174},"end":{"line":8,"column":7,"index":175},"identifierName":"A"}, + "start":268,"end":269,"loc":{"start":{"line":11,"column":6,"index":268},"end":{"line":11,"column":7,"index":269},"identifierName":"A"}, "name": "A" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":175,"end":184,"loc":{"start":{"line":8,"column":7,"index":175},"end":{"line":8,"column":16,"index":184}}, + "start":269,"end":278,"loc":{"start":{"line":11,"column":7,"index":269},"end":{"line":11,"column":16,"index":278}}, "params": [ { "type": "TSTypeParameter", - "start":176,"end":183,"loc":{"start":{"line":8,"column":8,"index":176},"end":{"line":8,"column":15,"index":183}}, + "start":270,"end":277,"loc":{"start":{"line":11,"column":8,"index":270},"end":{"line":11,"column":15,"index":277}}, "const": true, "name": { "type": "Identifier", - "start":182,"end":183,"loc":{"start":{"line":8,"column":14,"index":182},"end":{"line":8,"column":15,"index":183},"identifierName":"T"}, + "start":276,"end":277,"loc":{"start":{"line":11,"column":14,"index":276},"end":{"line":11,"column":15,"index":277},"identifierName":"T"}, "name": "T" } } @@ -260,37 +392,37 @@ "superClass": null, "body": { "type": "ClassBody", - "start":185,"end":187,"loc":{"start":{"line":8,"column":17,"index":185},"end":{"line":8,"column":19,"index":187}}, + "start":279,"end":281,"loc":{"start":{"line":11,"column":17,"index":279},"end":{"line":11,"column":19,"index":281}}, "body": [] } }, { "type": "ClassDeclaration", - "start":188,"end":217,"loc":{"start":{"line":9,"column":0,"index":188},"end":{"line":9,"column":29,"index":217}}, + "start":282,"end":311,"loc":{"start":{"line":12,"column":0,"index":282},"end":{"line":12,"column":29,"index":311}}, "id": { "type": "Identifier", - "start":194,"end":195,"loc":{"start":{"line":9,"column":6,"index":194},"end":{"line":9,"column":7,"index":195},"identifierName":"B"}, + "start":288,"end":289,"loc":{"start":{"line":12,"column":6,"index":288},"end":{"line":12,"column":7,"index":289},"identifierName":"B"}, "name": "B" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":195,"end":214,"loc":{"start":{"line":9,"column":7,"index":195},"end":{"line":9,"column":26,"index":214}}, + "start":289,"end":308,"loc":{"start":{"line":12,"column":7,"index":289},"end":{"line":12,"column":26,"index":308}}, "params": [ { "type": "TSTypeParameter", - "start":196,"end":213,"loc":{"start":{"line":9,"column":8,"index":196},"end":{"line":9,"column":25,"index":213}}, + "start":290,"end":307,"loc":{"start":{"line":12,"column":8,"index":290},"end":{"line":12,"column":25,"index":307}}, "const": true, "name": { "type": "Identifier", - "start":202,"end":203,"loc":{"start":{"line":9,"column":14,"index":202},"end":{"line":9,"column":15,"index":203},"identifierName":"T"}, + "start":296,"end":297,"loc":{"start":{"line":12,"column":14,"index":296},"end":{"line":12,"column":15,"index":297},"identifierName":"T"}, "name": "T" }, "constraint": { "type": "TSTypeReference", - "start":212,"end":213,"loc":{"start":{"line":9,"column":24,"index":212},"end":{"line":9,"column":25,"index":213}}, + "start":306,"end":307,"loc":{"start":{"line":12,"column":24,"index":306},"end":{"line":12,"column":25,"index":307}}, "typeName": { "type": "Identifier", - "start":212,"end":213,"loc":{"start":{"line":9,"column":24,"index":212},"end":{"line":9,"column":25,"index":213},"identifierName":"U"}, + "start":306,"end":307,"loc":{"start":{"line":12,"column":24,"index":306},"end":{"line":12,"column":25,"index":307},"identifierName":"U"}, "name": "U" } } @@ -300,38 +432,38 @@ "superClass": null, "body": { "type": "ClassBody", - "start":215,"end":217,"loc":{"start":{"line":9,"column":27,"index":215},"end":{"line":9,"column":29,"index":217}}, + "start":309,"end":311,"loc":{"start":{"line":12,"column":27,"index":309},"end":{"line":12,"column":29,"index":311}}, "body": [] } }, { "type": "ClassDeclaration", - "start":218,"end":240,"loc":{"start":{"line":10,"column":0,"index":218},"end":{"line":10,"column":22,"index":240}}, + "start":312,"end":334,"loc":{"start":{"line":13,"column":0,"index":312},"end":{"line":13,"column":22,"index":334}}, "id": { "type": "Identifier", - "start":224,"end":225,"loc":{"start":{"line":10,"column":6,"index":224},"end":{"line":10,"column":7,"index":225},"identifierName":"C"}, + "start":318,"end":319,"loc":{"start":{"line":13,"column":6,"index":318},"end":{"line":13,"column":7,"index":319},"identifierName":"C"}, "name": "C" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":225,"end":237,"loc":{"start":{"line":10,"column":7,"index":225},"end":{"line":10,"column":19,"index":237}}, + "start":319,"end":331,"loc":{"start":{"line":13,"column":7,"index":319},"end":{"line":13,"column":19,"index":331}}, "params": [ { "type": "TSTypeParameter", - "start":226,"end":227,"loc":{"start":{"line":10,"column":8,"index":226},"end":{"line":10,"column":9,"index":227}}, + "start":320,"end":321,"loc":{"start":{"line":13,"column":8,"index":320},"end":{"line":13,"column":9,"index":321}}, "name": { "type": "Identifier", - "start":226,"end":227,"loc":{"start":{"line":10,"column":8,"index":226},"end":{"line":10,"column":9,"index":227},"identifierName":"T"}, + "start":320,"end":321,"loc":{"start":{"line":13,"column":8,"index":320},"end":{"line":13,"column":9,"index":321},"identifierName":"T"}, "name": "T" } }, { "type": "TSTypeParameter", - "start":229,"end":236,"loc":{"start":{"line":10,"column":11,"index":229},"end":{"line":10,"column":18,"index":236}}, + "start":323,"end":330,"loc":{"start":{"line":13,"column":11,"index":323},"end":{"line":13,"column":18,"index":330}}, "const": true, "name": { "type": "Identifier", - "start":235,"end":236,"loc":{"start":{"line":10,"column":17,"index":235},"end":{"line":10,"column":18,"index":236},"identifierName":"U"}, + "start":329,"end":330,"loc":{"start":{"line":13,"column":17,"index":329},"end":{"line":13,"column":18,"index":330},"identifierName":"U"}, "name": "U" } } @@ -340,30 +472,30 @@ "superClass": null, "body": { "type": "ClassBody", - "start":238,"end":240,"loc":{"start":{"line":10,"column":20,"index":238},"end":{"line":10,"column":22,"index":240}}, + "start":332,"end":334,"loc":{"start":{"line":13,"column":20,"index":332},"end":{"line":13,"column":22,"index":334}}, "body": [] } }, { "type": "ClassDeclaration", - "start":241,"end":263,"loc":{"start":{"line":11,"column":0,"index":241},"end":{"line":11,"column":22,"index":263}}, + "start":335,"end":357,"loc":{"start":{"line":14,"column":0,"index":335},"end":{"line":14,"column":22,"index":357}}, "id": { "type": "Identifier", - "start":247,"end":248,"loc":{"start":{"line":11,"column":6,"index":247},"end":{"line":11,"column":7,"index":248},"identifierName":"D"}, + "start":341,"end":342,"loc":{"start":{"line":14,"column":6,"index":341},"end":{"line":14,"column":7,"index":342},"identifierName":"D"}, "name": "D" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":248,"end":260,"loc":{"start":{"line":11,"column":7,"index":248},"end":{"line":11,"column":19,"index":260}}, + "start":342,"end":354,"loc":{"start":{"line":14,"column":7,"index":342},"end":{"line":14,"column":19,"index":354}}, "params": [ { "type": "TSTypeParameter", - "start":249,"end":259,"loc":{"start":{"line":11,"column":8,"index":249},"end":{"line":11,"column":18,"index":259}}, + "start":343,"end":353,"loc":{"start":{"line":14,"column":8,"index":343},"end":{"line":14,"column":18,"index":353}}, "in": true, "const": true, "name": { "type": "Identifier", - "start":258,"end":259,"loc":{"start":{"line":11,"column":17,"index":258},"end":{"line":11,"column":18,"index":259},"identifierName":"T"}, + "start":352,"end":353,"loc":{"start":{"line":14,"column":17,"index":352},"end":{"line":14,"column":18,"index":353},"identifierName":"T"}, "name": "T" } } @@ -372,30 +504,30 @@ "superClass": null, "body": { "type": "ClassBody", - "start":261,"end":263,"loc":{"start":{"line":11,"column":20,"index":261},"end":{"line":11,"column":22,"index":263}}, + "start":355,"end":357,"loc":{"start":{"line":14,"column":20,"index":355},"end":{"line":14,"column":22,"index":357}}, "body": [] } }, { "type": "ClassDeclaration", - "start":264,"end":286,"loc":{"start":{"line":12,"column":0,"index":264},"end":{"line":12,"column":22,"index":286}}, + "start":358,"end":380,"loc":{"start":{"line":15,"column":0,"index":358},"end":{"line":15,"column":22,"index":380}}, "id": { "type": "Identifier", - "start":270,"end":271,"loc":{"start":{"line":12,"column":6,"index":270},"end":{"line":12,"column":7,"index":271},"identifierName":"E"}, + "start":364,"end":365,"loc":{"start":{"line":15,"column":6,"index":364},"end":{"line":15,"column":7,"index":365},"identifierName":"E"}, "name": "E" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":271,"end":283,"loc":{"start":{"line":12,"column":7,"index":271},"end":{"line":12,"column":19,"index":283}}, + "start":365,"end":377,"loc":{"start":{"line":15,"column":7,"index":365},"end":{"line":15,"column":19,"index":377}}, "params": [ { "type": "TSTypeParameter", - "start":272,"end":282,"loc":{"start":{"line":12,"column":8,"index":272},"end":{"line":12,"column":18,"index":282}}, + "start":366,"end":376,"loc":{"start":{"line":15,"column":8,"index":366},"end":{"line":15,"column":18,"index":376}}, "const": true, "in": true, "name": { "type": "Identifier", - "start":281,"end":282,"loc":{"start":{"line":12,"column":17,"index":281},"end":{"line":12,"column":18,"index":282},"identifierName":"T"}, + "start":375,"end":376,"loc":{"start":{"line":15,"column":17,"index":375},"end":{"line":15,"column":18,"index":376},"identifierName":"T"}, "name": "T" } } @@ -404,29 +536,224 @@ "superClass": null, "body": { "type": "ClassBody", - "start":284,"end":286,"loc":{"start":{"line":12,"column":20,"index":284},"end":{"line":12,"column":22,"index":286}}, + "start":378,"end":380,"loc":{"start":{"line":15,"column":20,"index":378},"end":{"line":15,"column":22,"index":380}}, "body": [] } }, + { + "type": "ExpressionStatement", + "start":381,"end":402,"loc":{"start":{"line":16,"column":0,"index":381},"end":{"line":16,"column":21,"index":402}}, + "expression": { + "type": "ClassExpression", + "start":382,"end":400,"loc":{"start":{"line":16,"column":1,"index":382},"end":{"line":16,"column":19,"index":400}}, + "id": null, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":388,"end":397,"loc":{"start":{"line":16,"column":7,"index":388},"end":{"line":16,"column":16,"index":397}}, + "params": [ + { + "type": "TSTypeParameter", + "start":389,"end":396,"loc":{"start":{"line":16,"column":8,"index":389},"end":{"line":16,"column":15,"index":396}}, + "const": true, + "name": { + "type": "Identifier", + "start":395,"end":396,"loc":{"start":{"line":16,"column":14,"index":395},"end":{"line":16,"column":15,"index":396},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":398,"end":400,"loc":{"start":{"line":16,"column":17,"index":398},"end":{"line":16,"column":19,"index":400}}, + "body": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 381 + } + } + }, + { + "type": "ExpressionStatement", + "start":403,"end":434,"loc":{"start":{"line":17,"column":0,"index":403},"end":{"line":17,"column":31,"index":434}}, + "expression": { + "type": "ClassExpression", + "start":404,"end":432,"loc":{"start":{"line":17,"column":1,"index":404},"end":{"line":17,"column":29,"index":432}}, + "id": null, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":410,"end":429,"loc":{"start":{"line":17,"column":7,"index":410},"end":{"line":17,"column":26,"index":429}}, + "params": [ + { + "type": "TSTypeParameter", + "start":411,"end":428,"loc":{"start":{"line":17,"column":8,"index":411},"end":{"line":17,"column":25,"index":428}}, + "const": true, + "name": { + "type": "Identifier", + "start":417,"end":418,"loc":{"start":{"line":17,"column":14,"index":417},"end":{"line":17,"column":15,"index":418},"identifierName":"T"}, + "name": "T" + }, + "constraint": { + "type": "TSTypeReference", + "start":427,"end":428,"loc":{"start":{"line":17,"column":24,"index":427},"end":{"line":17,"column":25,"index":428}}, + "typeName": { + "type": "Identifier", + "start":427,"end":428,"loc":{"start":{"line":17,"column":24,"index":427},"end":{"line":17,"column":25,"index":428},"identifierName":"U"}, + "name": "U" + } + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":430,"end":432,"loc":{"start":{"line":17,"column":27,"index":430},"end":{"line":17,"column":29,"index":432}}, + "body": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 403 + } + } + }, + { + "type": "ExpressionStatement", + "start":435,"end":459,"loc":{"start":{"line":18,"column":0,"index":435},"end":{"line":18,"column":24,"index":459}}, + "expression": { + "type": "ClassExpression", + "start":436,"end":457,"loc":{"start":{"line":18,"column":1,"index":436},"end":{"line":18,"column":22,"index":457}}, + "id": null, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":442,"end":454,"loc":{"start":{"line":18,"column":7,"index":442},"end":{"line":18,"column":19,"index":454}}, + "params": [ + { + "type": "TSTypeParameter", + "start":443,"end":444,"loc":{"start":{"line":18,"column":8,"index":443},"end":{"line":18,"column":9,"index":444}}, + "name": { + "type": "Identifier", + "start":443,"end":444,"loc":{"start":{"line":18,"column":8,"index":443},"end":{"line":18,"column":9,"index":444},"identifierName":"T"}, + "name": "T" + } + }, + { + "type": "TSTypeParameter", + "start":446,"end":453,"loc":{"start":{"line":18,"column":11,"index":446},"end":{"line":18,"column":18,"index":453}}, + "const": true, + "name": { + "type": "Identifier", + "start":452,"end":453,"loc":{"start":{"line":18,"column":17,"index":452},"end":{"line":18,"column":18,"index":453},"identifierName":"U"}, + "name": "U" + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":455,"end":457,"loc":{"start":{"line":18,"column":20,"index":455},"end":{"line":18,"column":22,"index":457}}, + "body": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 435 + } + } + }, + { + "type": "ExpressionStatement", + "start":460,"end":484,"loc":{"start":{"line":19,"column":0,"index":460},"end":{"line":19,"column":24,"index":484}}, + "expression": { + "type": "ClassExpression", + "start":461,"end":482,"loc":{"start":{"line":19,"column":1,"index":461},"end":{"line":19,"column":22,"index":482}}, + "id": null, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":467,"end":479,"loc":{"start":{"line":19,"column":7,"index":467},"end":{"line":19,"column":19,"index":479}}, + "params": [ + { + "type": "TSTypeParameter", + "start":468,"end":478,"loc":{"start":{"line":19,"column":8,"index":468},"end":{"line":19,"column":18,"index":478}}, + "in": true, + "const": true, + "name": { + "type": "Identifier", + "start":477,"end":478,"loc":{"start":{"line":19,"column":17,"index":477},"end":{"line":19,"column":18,"index":478},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":480,"end":482,"loc":{"start":{"line":19,"column":20,"index":480},"end":{"line":19,"column":22,"index":482}}, + "body": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 460 + } + } + }, + { + "type": "ExpressionStatement", + "start":485,"end":509,"loc":{"start":{"line":20,"column":0,"index":485},"end":{"line":20,"column":24,"index":509}}, + "expression": { + "type": "ClassExpression", + "start":486,"end":507,"loc":{"start":{"line":20,"column":1,"index":486},"end":{"line":20,"column":22,"index":507}}, + "id": null, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start":492,"end":504,"loc":{"start":{"line":20,"column":7,"index":492},"end":{"line":20,"column":19,"index":504}}, + "params": [ + { + "type": "TSTypeParameter", + "start":493,"end":503,"loc":{"start":{"line":20,"column":8,"index":493},"end":{"line":20,"column":18,"index":503}}, + "const": true, + "in": true, + "name": { + "type": "Identifier", + "start":502,"end":503,"loc":{"start":{"line":20,"column":17,"index":502},"end":{"line":20,"column":18,"index":503},"identifierName":"T"}, + "name": "T" + } + } + ] + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":505,"end":507,"loc":{"start":{"line":20,"column":20,"index":505},"end":{"line":20,"column":22,"index":507}}, + "body": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 485 + } + } + }, { "type": "TSInterfaceDeclaration", - "start":288,"end":311,"loc":{"start":{"line":14,"column":0,"index":288},"end":{"line":14,"column":23,"index":311}}, + "start":511,"end":534,"loc":{"start":{"line":22,"column":0,"index":511},"end":{"line":22,"column":23,"index":534}}, "id": { "type": "Identifier", - "start":298,"end":299,"loc":{"start":{"line":14,"column":10,"index":298},"end":{"line":14,"column":11,"index":299},"identifierName":"I"}, + "start":521,"end":522,"loc":{"start":{"line":22,"column":10,"index":521},"end":{"line":22,"column":11,"index":522},"identifierName":"I"}, "name": "I" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":299,"end":308,"loc":{"start":{"line":14,"column":11,"index":299},"end":{"line":14,"column":20,"index":308}}, + "start":522,"end":531,"loc":{"start":{"line":22,"column":11,"index":522},"end":{"line":22,"column":20,"index":531}}, "params": [ { "type": "TSTypeParameter", - "start":300,"end":307,"loc":{"start":{"line":14,"column":12,"index":300},"end":{"line":14,"column":19,"index":307}}, + "start":523,"end":530,"loc":{"start":{"line":22,"column":12,"index":523},"end":{"line":22,"column":19,"index":530}}, "const": true, "name": { "type": "Identifier", - "start":306,"end":307,"loc":{"start":{"line":14,"column":18,"index":306},"end":{"line":14,"column":19,"index":307},"identifierName":"T"}, + "start":529,"end":530,"loc":{"start":{"line":22,"column":18,"index":529},"end":{"line":22,"column":19,"index":530},"identifierName":"T"}, "name": "T" } } @@ -434,37 +761,37 @@ }, "body": { "type": "TSInterfaceBody", - "start":309,"end":311,"loc":{"start":{"line":14,"column":21,"index":309},"end":{"line":14,"column":23,"index":311}}, + "start":532,"end":534,"loc":{"start":{"line":22,"column":21,"index":532},"end":{"line":22,"column":23,"index":534}}, "body": [] } }, { "type": "TSInterfaceDeclaration", - "start":312,"end":345,"loc":{"start":{"line":15,"column":0,"index":312},"end":{"line":15,"column":33,"index":345}}, + "start":535,"end":568,"loc":{"start":{"line":23,"column":0,"index":535},"end":{"line":23,"column":33,"index":568}}, "id": { "type": "Identifier", - "start":322,"end":323,"loc":{"start":{"line":15,"column":10,"index":322},"end":{"line":15,"column":11,"index":323},"identifierName":"J"}, + "start":545,"end":546,"loc":{"start":{"line":23,"column":10,"index":545},"end":{"line":23,"column":11,"index":546},"identifierName":"J"}, "name": "J" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":323,"end":342,"loc":{"start":{"line":15,"column":11,"index":323},"end":{"line":15,"column":30,"index":342}}, + "start":546,"end":565,"loc":{"start":{"line":23,"column":11,"index":546},"end":{"line":23,"column":30,"index":565}}, "params": [ { "type": "TSTypeParameter", - "start":324,"end":341,"loc":{"start":{"line":15,"column":12,"index":324},"end":{"line":15,"column":29,"index":341}}, + "start":547,"end":564,"loc":{"start":{"line":23,"column":12,"index":547},"end":{"line":23,"column":29,"index":564}}, "const": true, "name": { "type": "Identifier", - "start":330,"end":331,"loc":{"start":{"line":15,"column":18,"index":330},"end":{"line":15,"column":19,"index":331},"identifierName":"T"}, + "start":553,"end":554,"loc":{"start":{"line":23,"column":18,"index":553},"end":{"line":23,"column":19,"index":554},"identifierName":"T"}, "name": "T" }, "constraint": { "type": "TSTypeReference", - "start":340,"end":341,"loc":{"start":{"line":15,"column":28,"index":340},"end":{"line":15,"column":29,"index":341}}, + "start":563,"end":564,"loc":{"start":{"line":23,"column":28,"index":563},"end":{"line":23,"column":29,"index":564}}, "typeName": { "type": "Identifier", - "start":340,"end":341,"loc":{"start":{"line":15,"column":28,"index":340},"end":{"line":15,"column":29,"index":341},"identifierName":"U"}, + "start":563,"end":564,"loc":{"start":{"line":23,"column":28,"index":563},"end":{"line":23,"column":29,"index":564},"identifierName":"U"}, "name": "U" } } @@ -473,38 +800,38 @@ }, "body": { "type": "TSInterfaceBody", - "start":343,"end":345,"loc":{"start":{"line":15,"column":31,"index":343},"end":{"line":15,"column":33,"index":345}}, + "start":566,"end":568,"loc":{"start":{"line":23,"column":31,"index":566},"end":{"line":23,"column":33,"index":568}}, "body": [] } }, { "type": "TSInterfaceDeclaration", - "start":346,"end":372,"loc":{"start":{"line":16,"column":0,"index":346},"end":{"line":16,"column":26,"index":372}}, + "start":569,"end":595,"loc":{"start":{"line":24,"column":0,"index":569},"end":{"line":24,"column":26,"index":595}}, "id": { "type": "Identifier", - "start":356,"end":357,"loc":{"start":{"line":16,"column":10,"index":356},"end":{"line":16,"column":11,"index":357},"identifierName":"K"}, + "start":579,"end":580,"loc":{"start":{"line":24,"column":10,"index":579},"end":{"line":24,"column":11,"index":580},"identifierName":"K"}, "name": "K" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":357,"end":369,"loc":{"start":{"line":16,"column":11,"index":357},"end":{"line":16,"column":23,"index":369}}, + "start":580,"end":592,"loc":{"start":{"line":24,"column":11,"index":580},"end":{"line":24,"column":23,"index":592}}, "params": [ { "type": "TSTypeParameter", - "start":358,"end":359,"loc":{"start":{"line":16,"column":12,"index":358},"end":{"line":16,"column":13,"index":359}}, + "start":581,"end":582,"loc":{"start":{"line":24,"column":12,"index":581},"end":{"line":24,"column":13,"index":582}}, "name": { "type": "Identifier", - "start":358,"end":359,"loc":{"start":{"line":16,"column":12,"index":358},"end":{"line":16,"column":13,"index":359},"identifierName":"T"}, + "start":581,"end":582,"loc":{"start":{"line":24,"column":12,"index":581},"end":{"line":24,"column":13,"index":582},"identifierName":"T"}, "name": "T" } }, { "type": "TSTypeParameter", - "start":361,"end":368,"loc":{"start":{"line":16,"column":15,"index":361},"end":{"line":16,"column":22,"index":368}}, + "start":584,"end":591,"loc":{"start":{"line":24,"column":15,"index":584},"end":{"line":24,"column":22,"index":591}}, "const": true, "name": { "type": "Identifier", - "start":367,"end":368,"loc":{"start":{"line":16,"column":21,"index":367},"end":{"line":16,"column":22,"index":368},"identifierName":"U"}, + "start":590,"end":591,"loc":{"start":{"line":24,"column":21,"index":590},"end":{"line":24,"column":22,"index":591},"identifierName":"U"}, "name": "U" } } @@ -512,30 +839,30 @@ }, "body": { "type": "TSInterfaceBody", - "start":370,"end":372,"loc":{"start":{"line":16,"column":24,"index":370},"end":{"line":16,"column":26,"index":372}}, + "start":593,"end":595,"loc":{"start":{"line":24,"column":24,"index":593},"end":{"line":24,"column":26,"index":595}}, "body": [] } }, { "type": "TSInterfaceDeclaration", - "start":373,"end":399,"loc":{"start":{"line":17,"column":0,"index":373},"end":{"line":17,"column":26,"index":399}}, + "start":596,"end":622,"loc":{"start":{"line":25,"column":0,"index":596},"end":{"line":25,"column":26,"index":622}}, "id": { "type": "Identifier", - "start":383,"end":384,"loc":{"start":{"line":17,"column":10,"index":383},"end":{"line":17,"column":11,"index":384},"identifierName":"L"}, + "start":606,"end":607,"loc":{"start":{"line":25,"column":10,"index":606},"end":{"line":25,"column":11,"index":607},"identifierName":"L"}, "name": "L" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":384,"end":396,"loc":{"start":{"line":17,"column":11,"index":384},"end":{"line":17,"column":23,"index":396}}, + "start":607,"end":619,"loc":{"start":{"line":25,"column":11,"index":607},"end":{"line":25,"column":23,"index":619}}, "params": [ { "type": "TSTypeParameter", - "start":385,"end":395,"loc":{"start":{"line":17,"column":12,"index":385},"end":{"line":17,"column":22,"index":395}}, + "start":608,"end":618,"loc":{"start":{"line":25,"column":12,"index":608},"end":{"line":25,"column":22,"index":618}}, "in": true, "const": true, "name": { "type": "Identifier", - "start":394,"end":395,"loc":{"start":{"line":17,"column":21,"index":394},"end":{"line":17,"column":22,"index":395},"identifierName":"T"}, + "start":617,"end":618,"loc":{"start":{"line":25,"column":21,"index":617},"end":{"line":25,"column":22,"index":618},"identifierName":"T"}, "name": "T" } } @@ -543,30 +870,30 @@ }, "body": { "type": "TSInterfaceBody", - "start":397,"end":399,"loc":{"start":{"line":17,"column":24,"index":397},"end":{"line":17,"column":26,"index":399}}, + "start":620,"end":622,"loc":{"start":{"line":25,"column":24,"index":620},"end":{"line":25,"column":26,"index":622}}, "body": [] } }, { "type": "TSInterfaceDeclaration", - "start":400,"end":426,"loc":{"start":{"line":18,"column":0,"index":400},"end":{"line":18,"column":26,"index":426}}, + "start":623,"end":649,"loc":{"start":{"line":26,"column":0,"index":623},"end":{"line":26,"column":26,"index":649}}, "id": { "type": "Identifier", - "start":410,"end":411,"loc":{"start":{"line":18,"column":10,"index":410},"end":{"line":18,"column":11,"index":411},"identifierName":"M"}, + "start":633,"end":634,"loc":{"start":{"line":26,"column":10,"index":633},"end":{"line":26,"column":11,"index":634},"identifierName":"M"}, "name": "M" }, "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":411,"end":423,"loc":{"start":{"line":18,"column":11,"index":411},"end":{"line":18,"column":23,"index":423}}, + "start":634,"end":646,"loc":{"start":{"line":26,"column":11,"index":634},"end":{"line":26,"column":23,"index":646}}, "params": [ { "type": "TSTypeParameter", - "start":412,"end":422,"loc":{"start":{"line":18,"column":12,"index":412},"end":{"line":18,"column":22,"index":422}}, + "start":635,"end":645,"loc":{"start":{"line":26,"column":12,"index":635},"end":{"line":26,"column":22,"index":645}}, "const": true, "in": true, "name": { "type": "Identifier", - "start":421,"end":422,"loc":{"start":{"line":18,"column":21,"index":421},"end":{"line":18,"column":22,"index":422},"identifierName":"T"}, + "start":644,"end":645,"loc":{"start":{"line":26,"column":21,"index":644},"end":{"line":26,"column":22,"index":645},"identifierName":"T"}, "name": "T" } } @@ -574,45 +901,45 @@ }, "body": { "type": "TSInterfaceBody", - "start":424,"end":426,"loc":{"start":{"line":18,"column":24,"index":424},"end":{"line":18,"column":26,"index":426}}, + "start":647,"end":649,"loc":{"start":{"line":26,"column":24,"index":647},"end":{"line":26,"column":26,"index":649}}, "body": [] } }, { "type": "ClassDeclaration", - "start":428,"end":521,"loc":{"start":{"line":20,"column":0,"index":428},"end":{"line":24,"column":1,"index":521}}, + "start":651,"end":744,"loc":{"start":{"line":28,"column":0,"index":651},"end":{"line":32,"column":1,"index":744}}, "id": { "type": "Identifier", - "start":434,"end":435,"loc":{"start":{"line":20,"column":6,"index":434},"end":{"line":20,"column":7,"index":435},"identifierName":"_"}, + "start":657,"end":658,"loc":{"start":{"line":28,"column":6,"index":657},"end":{"line":28,"column":7,"index":658},"identifierName":"_"}, "name": "_" }, "superClass": null, "body": { "type": "ClassBody", - "start":436,"end":521,"loc":{"start":{"line":20,"column":8,"index":436},"end":{"line":24,"column":1,"index":521}}, + "start":659,"end":744,"loc":{"start":{"line":28,"column":8,"index":659},"end":{"line":32,"column":1,"index":744}}, "body": [ { "type": "ClassMethod", - "start":440,"end":460,"loc":{"start":{"line":21,"column":2,"index":440},"end":{"line":21,"column":22,"index":460}}, + "start":663,"end":683,"loc":{"start":{"line":29,"column":2,"index":663},"end":{"line":29,"column":22,"index":683}}, "static": false, "key": { "type": "Identifier", - "start":440,"end":446,"loc":{"start":{"line":21,"column":2,"index":440},"end":{"line":21,"column":8,"index":446},"identifierName":"method"}, + "start":663,"end":669,"loc":{"start":{"line":29,"column":2,"index":663},"end":{"line":29,"column":8,"index":669},"identifierName":"method"}, "name": "method" }, "computed": false, "kind": "method", "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":446,"end":455,"loc":{"start":{"line":21,"column":8,"index":446},"end":{"line":21,"column":17,"index":455}}, + "start":669,"end":678,"loc":{"start":{"line":29,"column":8,"index":669},"end":{"line":29,"column":17,"index":678}}, "params": [ { "type": "TSTypeParameter", - "start":447,"end":454,"loc":{"start":{"line":21,"column":9,"index":447},"end":{"line":21,"column":16,"index":454}}, + "start":670,"end":677,"loc":{"start":{"line":29,"column":9,"index":670},"end":{"line":29,"column":16,"index":677}}, "const": true, "name": { "type": "Identifier", - "start":453,"end":454,"loc":{"start":{"line":21,"column":15,"index":453},"end":{"line":21,"column":16,"index":454},"identifierName":"T"}, + "start":676,"end":677,"loc":{"start":{"line":29,"column":15,"index":676},"end":{"line":29,"column":16,"index":677},"identifierName":"T"}, "name": "T" } } @@ -624,41 +951,41 @@ "params": [], "body": { "type": "BlockStatement", - "start":458,"end":460,"loc":{"start":{"line":21,"column":20,"index":458},"end":{"line":21,"column":22,"index":460}}, + "start":681,"end":683,"loc":{"start":{"line":29,"column":20,"index":681},"end":{"line":29,"column":22,"index":683}}, "body": [], "directives": [] } }, { "type": "ClassMethod", - "start":463,"end":493,"loc":{"start":{"line":22,"column":2,"index":463},"end":{"line":22,"column":32,"index":493}}, + "start":686,"end":716,"loc":{"start":{"line":30,"column":2,"index":686},"end":{"line":30,"column":32,"index":716}}, "static": false, "key": { "type": "Identifier", - "start":463,"end":469,"loc":{"start":{"line":22,"column":2,"index":463},"end":{"line":22,"column":8,"index":469},"identifierName":"method"}, + "start":686,"end":692,"loc":{"start":{"line":30,"column":2,"index":686},"end":{"line":30,"column":8,"index":692},"identifierName":"method"}, "name": "method" }, "computed": false, "kind": "method", "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":469,"end":488,"loc":{"start":{"line":22,"column":8,"index":469},"end":{"line":22,"column":27,"index":488}}, + "start":692,"end":711,"loc":{"start":{"line":30,"column":8,"index":692},"end":{"line":30,"column":27,"index":711}}, "params": [ { "type": "TSTypeParameter", - "start":470,"end":487,"loc":{"start":{"line":22,"column":9,"index":470},"end":{"line":22,"column":26,"index":487}}, + "start":693,"end":710,"loc":{"start":{"line":30,"column":9,"index":693},"end":{"line":30,"column":26,"index":710}}, "const": true, "name": { "type": "Identifier", - "start":476,"end":477,"loc":{"start":{"line":22,"column":15,"index":476},"end":{"line":22,"column":16,"index":477},"identifierName":"T"}, + "start":699,"end":700,"loc":{"start":{"line":30,"column":15,"index":699},"end":{"line":30,"column":16,"index":700},"identifierName":"T"}, "name": "T" }, "constraint": { "type": "TSTypeReference", - "start":486,"end":487,"loc":{"start":{"line":22,"column":25,"index":486},"end":{"line":22,"column":26,"index":487}}, + "start":709,"end":710,"loc":{"start":{"line":30,"column":25,"index":709},"end":{"line":30,"column":26,"index":710}}, "typeName": { "type": "Identifier", - "start":486,"end":487,"loc":{"start":{"line":22,"column":25,"index":486},"end":{"line":22,"column":26,"index":487},"identifierName":"U"}, + "start":709,"end":710,"loc":{"start":{"line":30,"column":25,"index":709},"end":{"line":30,"column":26,"index":710},"identifierName":"U"}, "name": "U" } } @@ -671,42 +998,42 @@ "params": [], "body": { "type": "BlockStatement", - "start":491,"end":493,"loc":{"start":{"line":22,"column":30,"index":491},"end":{"line":22,"column":32,"index":493}}, + "start":714,"end":716,"loc":{"start":{"line":30,"column":30,"index":714},"end":{"line":30,"column":32,"index":716}}, "body": [], "directives": [] } }, { "type": "ClassMethod", - "start":496,"end":519,"loc":{"start":{"line":23,"column":2,"index":496},"end":{"line":23,"column":25,"index":519}}, + "start":719,"end":742,"loc":{"start":{"line":31,"column":2,"index":719},"end":{"line":31,"column":25,"index":742}}, "static": false, "key": { "type": "Identifier", - "start":496,"end":502,"loc":{"start":{"line":23,"column":2,"index":496},"end":{"line":23,"column":8,"index":502},"identifierName":"method"}, + "start":719,"end":725,"loc":{"start":{"line":31,"column":2,"index":719},"end":{"line":31,"column":8,"index":725},"identifierName":"method"}, "name": "method" }, "computed": false, "kind": "method", "typeParameters": { "type": "TSTypeParameterDeclaration", - "start":502,"end":514,"loc":{"start":{"line":23,"column":8,"index":502},"end":{"line":23,"column":20,"index":514}}, + "start":725,"end":737,"loc":{"start":{"line":31,"column":8,"index":725},"end":{"line":31,"column":20,"index":737}}, "params": [ { "type": "TSTypeParameter", - "start":503,"end":504,"loc":{"start":{"line":23,"column":9,"index":503},"end":{"line":23,"column":10,"index":504}}, + "start":726,"end":727,"loc":{"start":{"line":31,"column":9,"index":726},"end":{"line":31,"column":10,"index":727}}, "name": { "type": "Identifier", - "start":503,"end":504,"loc":{"start":{"line":23,"column":9,"index":503},"end":{"line":23,"column":10,"index":504},"identifierName":"T"}, + "start":726,"end":727,"loc":{"start":{"line":31,"column":9,"index":726},"end":{"line":31,"column":10,"index":727},"identifierName":"T"}, "name": "T" } }, { "type": "TSTypeParameter", - "start":506,"end":513,"loc":{"start":{"line":23,"column":12,"index":506},"end":{"line":23,"column":19,"index":513}}, + "start":729,"end":736,"loc":{"start":{"line":31,"column":12,"index":729},"end":{"line":31,"column":19,"index":736}}, "const": true, "name": { "type": "Identifier", - "start":512,"end":513,"loc":{"start":{"line":23,"column":18,"index":512},"end":{"line":23,"column":19,"index":513},"identifierName":"U"}, + "start":735,"end":736,"loc":{"start":{"line":31,"column":18,"index":735},"end":{"line":31,"column":19,"index":736},"identifierName":"U"}, "name": "U" } } @@ -718,7 +1045,7 @@ "params": [], "body": { "type": "BlockStatement", - "start":517,"end":519,"loc":{"start":{"line":23,"column":23,"index":517},"end":{"line":23,"column":25,"index":519}}, + "start":740,"end":742,"loc":{"start":{"line":31,"column":23,"index":740},"end":{"line":31,"column":25,"index":742}}, "body": [], "directives": [] } From ab6296e7fd6760c9e0ba2c93eb86f8577b5758c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sat, 18 Feb 2023 17:11:45 +0100 Subject: [PATCH 3/3] Ignore test where prettier expects Babel failure --- scripts/integration-tests/e2e-prettier.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/integration-tests/e2e-prettier.sh b/scripts/integration-tests/e2e-prettier.sh index 14cf25d53fe0..c210d549a67a 100755 --- a/scripts/integration-tests/e2e-prettier.sh +++ b/scripts/integration-tests/e2e-prettier.sh @@ -48,6 +48,8 @@ echo "export default () => () => {}" > src/main/create-print-pre-check-function. # because prettier has ignored UnexpectedReservedWord error rm -f tests/format/flow-repo/async/await_parse.js rm -f tests/format/misc/errors/js/explicit-resource-management/invalid-using-binding-await.js +# https://github.com/babel/babel/pull/15384 +rm -f tests/format/misc/errors/typescript/modifiers/jsfmt.spec.js yarn test "tests/format/(jsx?|misc|typescript|flow|flow-repo)/" --update-snapshot --runInBand