[babel 8] fix properties name for function-like TS nodes (#13709)
* Align AST * Add tests for parser * Generator * Add babel-types support * Address review * Address review
This commit is contained in:
parent
335622f75d
commit
69246b6212
@ -225,7 +225,10 @@ export function tsPrintFunctionOrConstructorType(
|
||||
// todo: missing type FunctionOrConstructorType
|
||||
node: any,
|
||||
) {
|
||||
const { typeParameters, parameters } = node;
|
||||
const { typeParameters } = node;
|
||||
const parameters = process.env.BABEL_8_BREAKING
|
||||
? node.params
|
||||
: node.parameters;
|
||||
this.print(typeParameters, node);
|
||||
this.token("(");
|
||||
this._parameters(parameters, node);
|
||||
@ -233,7 +236,10 @@ export function tsPrintFunctionOrConstructorType(
|
||||
this.space();
|
||||
this.token("=>");
|
||||
this.space();
|
||||
this.print(node.typeAnnotation.typeAnnotation, node);
|
||||
const returnType = process.env.BABEL_8_BREAKING
|
||||
? node.returnType
|
||||
: node.typeAnnotation;
|
||||
this.print(returnType.typeAnnotation, node);
|
||||
}
|
||||
|
||||
export function TSTypeReference(this: Printer, node: t.TSTypeReference) {
|
||||
@ -648,12 +654,18 @@ export function TSNamespaceExportDeclaration(
|
||||
}
|
||||
|
||||
export function tsPrintSignatureDeclarationBase(this: Printer, node: any) {
|
||||
const { typeParameters, parameters } = node;
|
||||
const { typeParameters } = node;
|
||||
const parameters = process.env.BABEL_8_BREAKING
|
||||
? node.params
|
||||
: node.parameters;
|
||||
this.print(typeParameters, node);
|
||||
this.token("(");
|
||||
this._parameters(parameters, node);
|
||||
this.token(")");
|
||||
this.print(node.typeAnnotation, node);
|
||||
const returnType = process.env.BABEL_8_BREAKING
|
||||
? node.returnType
|
||||
: node.typeAnnotation;
|
||||
this.print(returnType, node);
|
||||
}
|
||||
|
||||
export function tsPrintClassMemberModifiers(this: Printer, node: any, isField) {
|
||||
|
||||
@ -584,14 +584,21 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
): void {
|
||||
// Arrow fns *must* have return token (`=>`). Normal functions can omit it.
|
||||
const returnTokenRequired = returnToken === tt.arrow;
|
||||
|
||||
// https://github.com/babel/babel/issues/9231
|
||||
const paramsKey = process.env.BABEL_8_BREAKING ? "params" : "parameters";
|
||||
const returnTypeKey = process.env.BABEL_8_BREAKING
|
||||
? "returnType"
|
||||
: "typeAnnotation";
|
||||
|
||||
signature.typeParameters = this.tsTryParseTypeParameters();
|
||||
this.expect(tt.parenL);
|
||||
signature.parameters = this.tsParseBindingListForSignature();
|
||||
signature[paramsKey] = this.tsParseBindingListForSignature();
|
||||
if (returnTokenRequired) {
|
||||
signature.typeAnnotation =
|
||||
signature[returnTypeKey] =
|
||||
this.tsParseTypeOrTypePredicateAnnotation(returnToken);
|
||||
} else if (this.match(returnToken)) {
|
||||
signature.typeAnnotation =
|
||||
signature[returnTypeKey] =
|
||||
this.tsParseTypeOrTypePredicateAnnotation(returnToken);
|
||||
}
|
||||
}
|
||||
@ -683,10 +690,16 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
this.tsFillSignature(tt.colon, method);
|
||||
this.tsParseTypeMemberSemicolon();
|
||||
const paramsKey = process.env.BABEL_8_BREAKING
|
||||
? "params"
|
||||
: "parameters";
|
||||
const returnTypeKey = process.env.BABEL_8_BREAKING
|
||||
? "returnType"
|
||||
: "typeAnnotation";
|
||||
if (method.kind === "get") {
|
||||
if (method.parameters.length > 0) {
|
||||
if (method[paramsKey].length > 0) {
|
||||
this.raise(this.state.pos, Errors.BadGetterArity);
|
||||
if (this.isThisParam(method.parameters[0])) {
|
||||
if (this.isThisParam(method[paramsKey][0])) {
|
||||
this.raise(
|
||||
this.state.pos,
|
||||
TSErrors.AccesorCannotDeclareThisParameter,
|
||||
@ -694,10 +707,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
} else if (method.kind === "set") {
|
||||
if (method.parameters.length !== 1) {
|
||||
if (method[paramsKey].length !== 1) {
|
||||
this.raise(this.state.pos, Errors.BadSetterArity);
|
||||
} else {
|
||||
const firstParameter = method.parameters[0];
|
||||
const firstParameter = method[paramsKey][0];
|
||||
if (this.isThisParam(firstParameter)) {
|
||||
this.raise(
|
||||
this.state.pos,
|
||||
@ -720,9 +733,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
);
|
||||
}
|
||||
}
|
||||
if (method.typeAnnotation) {
|
||||
if (method[returnTypeKey]) {
|
||||
this.raise(
|
||||
method.typeAnnotation.start,
|
||||
method[returnTypeKey].start,
|
||||
TSErrors.SetAccesorCannotHaveReturnType,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1255,6 +1255,11 @@ export type TsSignatureDeclaration =
|
||||
|
||||
export type TsSignatureDeclarationOrIndexSignatureBase = NodeBase & {
|
||||
// Not using TypeScript's "ParameterDeclaration" here, since it's inconsistent with regular functions.
|
||||
params: $ReadOnlyArray<
|
||||
Identifier | RestElement | ObjectPattern | ArrayPattern,
|
||||
>,
|
||||
returnType: ?TsTypeAnnotation,
|
||||
// TODO(Babel-8): Remove
|
||||
parameters: $ReadOnlyArray<
|
||||
Identifier | RestElement | ObjectPattern | ArrayPattern,
|
||||
>,
|
||||
|
||||
5
packages/babel-parser/test/fixtures/typescript/declare/pattern-parameters-babel-7/input.ts
vendored
Normal file
5
packages/babel-parser/test/fixtures/typescript/declare/pattern-parameters-babel-7/input.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
declare interface B {
|
||||
foo([]?): void;
|
||||
bar({}, []?): any;
|
||||
baz(a: string, b: number, []?): void;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
141
packages/babel-parser/test/fixtures/typescript/declare/pattern-parameters-babel-7/output.json
vendored
Normal file
141
packages/babel-parser/test/fixtures/typescript/declare/pattern-parameters-babel-7/output.json
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":102,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":102,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":102,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19},"identifierName":"B"},
|
||||
"name": "B"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":20,"end":102,"loc":{"start":{"line":1,"column":20},"end":{"line":5,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":24,"end":39,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":17}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":24,"end":27,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":28,"end":31,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9}},
|
||||
"elements": [],
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":32,"end":38,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":16}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":34,"end":38,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":16}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":42,"end":60,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":20}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":42,"end":45,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":5},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "ObjectPattern",
|
||||
"start":46,"end":48,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":8}},
|
||||
"properties": []
|
||||
},
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":50,"end":53,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":13}},
|
||||
"elements": [],
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":54,"end":59,"loc":{"start":{"line":3,"column":14},"end":{"line":3,"column":19}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSAnyKeyword",
|
||||
"start":56,"end":59,"loc":{"start":{"line":3,"column":16},"end":{"line":3,"column":19}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":63,"end":100,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":39}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":63,"end":66,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":5},"identifierName":"baz"},
|
||||
"name": "baz"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":67,"end":76,"loc":{"start":{"line":4,"column":6},"end":{"line":4,"column":15},"identifierName":"a"},
|
||||
"name": "a",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":68,"end":76,"loc":{"start":{"line":4,"column":7},"end":{"line":4,"column":15}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":70,"end":76,"loc":{"start":{"line":4,"column":9},"end":{"line":4,"column":15}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":78,"end":87,"loc":{"start":{"line":4,"column":17},"end":{"line":4,"column":26},"identifierName":"b"},
|
||||
"name": "b",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":79,"end":87,"loc":{"start":{"line":4,"column":18},"end":{"line":4,"column":26}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start":81,"end":87,"loc":{"start":{"line":4,"column":20},"end":{"line":4,"column":26}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":89,"end":92,"loc":{"start":{"line":4,"column":28},"end":{"line":4,"column":31}},
|
||||
"elements": [],
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":93,"end":99,"loc":{"start":{"line":4,"column":32},"end":{"line":4,"column":38}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":95,"end":99,"loc":{"start":{"line":4,"column":34},"end":{"line":4,"column":38}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
}
|
||||
]
|
||||
},
|
||||
"declare": true
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/declare/pattern-parameters/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/declare/pattern-parameters/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -28,7 +28,7 @@
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":28,"end":31,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9}},
|
||||
@ -36,7 +36,7 @@
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":32,"end":38,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":16}},
|
||||
"typeAnnotation": {
|
||||
@ -55,7 +55,7 @@
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "ObjectPattern",
|
||||
"start":46,"end":48,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":8}},
|
||||
@ -68,7 +68,7 @@
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":54,"end":59,"loc":{"start":{"line":3,"column":14},"end":{"line":3,"column":19}},
|
||||
"typeAnnotation": {
|
||||
@ -87,7 +87,7 @@
|
||||
"name": "baz"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":67,"end":76,"loc":{"start":{"line":4,"column":6},"end":{"line":4,"column":15},"identifierName":"a"},
|
||||
@ -121,7 +121,7 @@
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":93,"end":99,"loc":{"start":{"line":4,"column":32},"end":{"line":4,"column":38}},
|
||||
"typeAnnotation": {
|
||||
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/call-signature-babel-7/input.ts
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/call-signature-babel-7/input.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
interface I {
|
||||
(x: number): void;
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/call-signature-babel-7/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/call-signature-babel-7/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
55
packages/babel-parser/test/fixtures/typescript/interface/call-signature-babel-7/output.json
vendored
Normal file
55
packages/babel-parser/test/fixtures/typescript/interface/call-signature-babel-7/output.json
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"I"},
|
||||
"name": "I"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSCallSignatureDeclaration",
|
||||
"start":18,"end":36,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":22}},
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":19,"end":28,"loc":{"start":{"line":2,"column":5},"end":{"line":2,"column":14},"identifierName":"x"},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":20,"end":28,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":14}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start":22,"end":28,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":14}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":29,"end":35,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":21}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":31,"end":35,"loc":{"start":{"line":2,"column":17},"end":{"line":2,"column":21}}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/call-signature/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/call-signature/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -22,7 +22,7 @@
|
||||
{
|
||||
"type": "TSCallSignatureDeclaration",
|
||||
"start":18,"end":36,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":22}},
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":19,"end":28,"loc":{"start":{"line":2,"column":5},"end":{"line":2,"column":14},"identifierName":"x"},
|
||||
@ -37,7 +37,7 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":29,"end":35,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":21}},
|
||||
"typeAnnotation": {
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
interface I {
|
||||
new (x: number): void;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
55
packages/babel-parser/test/fixtures/typescript/interface/construct-signature-babel-7/output.json
vendored
Normal file
55
packages/babel-parser/test/fixtures/typescript/interface/construct-signature-babel-7/output.json
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"I"},
|
||||
"name": "I"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":12,"end":42,"loc":{"start":{"line":1,"column":12},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSConstructSignatureDeclaration",
|
||||
"start":18,"end":40,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":26}},
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":23,"end":32,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":18},"identifierName":"x"},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":24,"end":32,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":18}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start":26,"end":32,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":18}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":33,"end":39,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":25}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":35,"end":39,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":25}}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/construct-signature/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/construct-signature/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -22,7 +22,7 @@
|
||||
{
|
||||
"type": "TSConstructSignatureDeclaration",
|
||||
"start":18,"end":40,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":26}},
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":23,"end":32,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":18},"identifierName":"x"},
|
||||
@ -37,7 +37,7 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":33,"end":39,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":25}},
|
||||
"typeAnnotation": {
|
||||
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-1/input.ts
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-1/input.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
interface Foo {
|
||||
<T>(a: string): string;
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-1/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-1/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
70
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-1/output.json
vendored
Normal file
70
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-1/output.json
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":43,"loc":{"start":{"line":1,"column":14},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSCallSignatureDeclaration",
|
||||
"start":18,"end":41,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":25}},
|
||||
"typeParameters": {
|
||||
"type": "TSTypeParameterDeclaration",
|
||||
"start":18,"end":21,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TSTypeParameter",
|
||||
"start":19,"end":20,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":4}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":19,"end":20,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":4},"identifierName":"T"},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":22,"end":31,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":15},"identifierName":"a"},
|
||||
"name": "a",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":23,"end":31,"loc":{"start":{"line":2,"column":7},"end":{"line":2,"column":15}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":25,"end":31,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":15}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":32,"end":40,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":24}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":34,"end":40,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":24}}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-2/input.ts
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-2/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
type Foo = <T>() => number;
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-2/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-2/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
50
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-2/output.json
vendored
Normal file
50
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-2/output.json
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSTypeAliasDeclaration",
|
||||
"start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":8,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":8},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSFunctionType",
|
||||
"start":11,"end":26,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":26}},
|
||||
"typeParameters": {
|
||||
"type": "TSTypeParameterDeclaration",
|
||||
"start":11,"end":14,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":14}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TSTypeParameter",
|
||||
"start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13},"identifierName":"T"},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":17,"end":26,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":26}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start":20,"end":26,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":26}}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-3/input.ts
vendored
Normal file
1
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-3/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
type Foo = new <T>() => void;
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-3/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-3/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
51
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-3/output.json
vendored
Normal file
51
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-3/output.json
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSTypeAliasDeclaration",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":8,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":8},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSConstructorType",
|
||||
"start":11,"end":28,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":28}},
|
||||
"abstract": false,
|
||||
"typeParameters": {
|
||||
"type": "TSTypeParameterDeclaration",
|
||||
"start":15,"end":18,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":18}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TSTypeParameter",
|
||||
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17},"identifierName":"T"},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":21,"end":28,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":28}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":24,"end":28,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":28}}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-4/input.ts
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-4/input.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
interface Foo {
|
||||
new<T>(a: string): string;
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-4/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-4/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
70
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-4/output.json
vendored
Normal file
70
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-4/output.json
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":46,"loc":{"start":{"line":1,"column":14},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSConstructSignatureDeclaration",
|
||||
"start":18,"end":44,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":28}},
|
||||
"typeParameters": {
|
||||
"type": "TSTypeParameterDeclaration",
|
||||
"start":21,"end":24,"loc":{"start":{"line":2,"column":5},"end":{"line":2,"column":8}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TSTypeParameter",
|
||||
"start":22,"end":23,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":7}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":23,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":7},"identifierName":"T"},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":25,"end":34,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":18},"identifierName":"a"},
|
||||
"name": "a",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":26,"end":34,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":18}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":28,"end":34,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":18}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":35,"end":43,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":27}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":37,"end":43,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":27}}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-5/input.ts
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-5/input.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
interface Foo {
|
||||
foo<T>(x: number): void;
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-5/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-5/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
77
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-5/output.json
vendored
Normal file
77
packages/babel-parser/test/fixtures/typescript/interface/function-like-node-5/output.json
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":44,"loc":{"start":{"line":1,"column":14},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":42,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":26}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":18,"end":21,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"typeParameters": {
|
||||
"type": "TSTypeParameterDeclaration",
|
||||
"start":21,"end":24,"loc":{"start":{"line":2,"column":5},"end":{"line":2,"column":8}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TSTypeParameter",
|
||||
"start":22,"end":23,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":7}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":23,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":7},"identifierName":"T"},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":25,"end":34,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":18},"identifierName":"x"},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":26,"end":34,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":18}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start":28,"end":34,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":18}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":35,"end":41,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":25}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":37,"end":41,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":25}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
6
packages/babel-parser/test/fixtures/typescript/interface/get-set-ambiguous-babel-7/input.ts
vendored
Normal file
6
packages/babel-parser/test/fixtures/typescript/interface/get-set-ambiguous-babel-7/input.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
interface Foo {
|
||||
get
|
||||
foo(): string;
|
||||
set
|
||||
bar(v);
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
86
packages/babel-parser/test/fixtures/typescript/interface/get-set-ambiguous-babel-7/output.json
vendored
Normal file
86
packages/babel-parser/test/fixtures/typescript/interface/get-set-ambiguous-babel-7/output.json
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":56,"loc":{"start":{"line":1,"column":14},"end":{"line":6,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSPropertySignature",
|
||||
"start":18,"end":21,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":18,"end":21,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5},"identifierName":"get"},
|
||||
"name": "get"
|
||||
},
|
||||
"computed": false
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":24,"end":38,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":16}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":24,"end":27,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":5},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":29,"end":37,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":15}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":31,"end":37,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":15}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSPropertySignature",
|
||||
"start":41,"end":44,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":5}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":41,"end":44,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":5},"identifierName":"set"},
|
||||
"name": "set"
|
||||
},
|
||||
"computed": false
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":47,"end":54,"loc":{"start":{"line":5,"column":2},"end":{"line":5,"column":9}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":47,"end":50,"loc":{"start":{"line":5,"column":2},"end":{"line":5,"column":5},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":51,"end":52,"loc":{"start":{"line":5,"column":6},"end":{"line":5,"column":7},"identifierName":"v"},
|
||||
"name": "v"
|
||||
}
|
||||
],
|
||||
"kind": "method"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/get-set-ambiguous/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/get-set-ambiguous/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -38,8 +38,8 @@
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":29,"end":37,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":15}},
|
||||
"typeAnnotation": {
|
||||
@ -68,7 +68,7 @@
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":51,"end":52,"loc":{"start":{"line":5,"column":6},"end":{"line":5,"column":7},"identifierName":"v"},
|
||||
|
||||
4
packages/babel-parser/test/fixtures/typescript/interface/get-set-babel-7/input.ts
vendored
Normal file
4
packages/babel-parser/test/fixtures/typescript/interface/get-set-babel-7/input.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
interface Foo {
|
||||
get foo(): string;
|
||||
set bar(v);
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/get-set-babel-7/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/get-set-babel-7/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
66
packages/babel-parser/test/fixtures/typescript/interface/get-set-babel-7/output.json
vendored
Normal file
66
packages/babel-parser/test/fixtures/typescript/interface/get-set-babel-7/output.json
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":52,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":52,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":52,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":52,"loc":{"start":{"line":1,"column":14},"end":{"line":4,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":36,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":20}},
|
||||
"kind": "get",
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":25,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":27,"end":35,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":19}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":29,"end":35,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":19}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":39,"end":50,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":13}},
|
||||
"kind": "set",
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":43,"end":46,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":9},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":47,"end":48,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":11},"identifierName":"v"},
|
||||
"name": "v"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
interface Foo {
|
||||
set bar(foo?: string);
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: A 'set' accessor cannot have an optional parameter. (3:1)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":42,"loc":{"start":{"line":1,"column":14},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":40,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":24}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":25,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "set",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":26,"end":38,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":22},"identifierName":"foo"},
|
||||
"name": "foo",
|
||||
"optional": true,
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":30,"end":38,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":22}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":32,"end":38,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":22}}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -32,7 +32,7 @@
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "set",
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":26,"end":38,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":22},"identifierName":"foo"},
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
interface Foo {
|
||||
get foo(param): string;
|
||||
set foo();
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: A 'get' accesor must not have any formal parameters. (3:5)",
|
||||
"SyntaxError: A 'set' accesor must have exactly one formal parameter. (4:1)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":56,"loc":{"start":{"line":1,"column":14},"end":{"line":4,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":41,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":25}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":25,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "get",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":26,"end":31,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":15},"identifierName":"param"},
|
||||
"name": "param"
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":32,"end":40,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":24}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":34,"end":40,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":24}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":44,"end":54,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":12}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":48,"end":51,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":9},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "set",
|
||||
"parameters": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -33,14 +33,14 @@
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "get",
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":26,"end":31,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":15},"identifierName":"param"},
|
||||
"name": "param"
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":32,"end":40,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":24}},
|
||||
"typeAnnotation": {
|
||||
@ -59,7 +59,7 @@
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "set",
|
||||
"parameters": []
|
||||
"params": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
interface Foo {
|
||||
set bar(...v);
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: A 'set' accessor cannot have rest parameter. (3:1)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":34,"loc":{"start":{"line":1,"column":14},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":32,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":16}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":25,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "set",
|
||||
"params": [
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":26,"end":30,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":14}},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start":29,"end":30,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":14},"identifierName":"v"},
|
||||
"name": "v"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -32,7 +32,7 @@
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "set",
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":26,"end":30,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":14}},
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
interface Foo {
|
||||
set foo(param): string;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: A 'set' accessor cannot have a return type annotation. (2:16)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":43,"loc":{"start":{"line":1,"column":14},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":41,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":25}},
|
||||
"kind": "set",
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":25,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":26,"end":31,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":15},"identifierName":"param"},
|
||||
"name": "param"
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":32,"end":40,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":24}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":34,"end":40,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":24}}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -32,14 +32,14 @@
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "set",
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":26,"end":31,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":15},"identifierName":"param"},
|
||||
"name": "param"
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":32,"end":40,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":24}},
|
||||
"typeAnnotation": {
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
interface Foo {
|
||||
get bar(this: Foo);
|
||||
set bar(this: Foo);
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: A 'get' accesor must not have any formal parameters. (3:5)",
|
||||
"SyntaxError: 'get' and 'set' accessors cannot declare 'this' parameters. (3:5)",
|
||||
"SyntaxError: 'get' and 'set' accessors cannot declare 'this' parameters. (4:1)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":61,"loc":{"start":{"line":1,"column":14},"end":{"line":4,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":37,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":21}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":25,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "get",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":26,"end":35,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":19},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":30,"end":35,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":19}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeReference",
|
||||
"start":32,"end":35,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":19}},
|
||||
"typeName": {
|
||||
"type": "Identifier",
|
||||
"start":32,"end":35,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":19},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":40,"end":59,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":21}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":44,"end":47,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":9},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "set",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":48,"end":57,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":19},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":52,"end":57,"loc":{"start":{"line":3,"column":14},"end":{"line":3,"column":19}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeReference",
|
||||
"start":54,"end":57,"loc":{"start":{"line":3,"column":16},"end":{"line":3,"column":19}},
|
||||
"typeName": {
|
||||
"type": "Identifier",
|
||||
"start":54,"end":57,"loc":{"start":{"line":3,"column":16},"end":{"line":3,"column":19},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -34,7 +34,7 @@
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "get",
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":26,"end":35,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":19},"identifierName":"this"},
|
||||
@ -65,7 +65,7 @@
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "set",
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":48,"end":57,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":19},"identifierName":"this"},
|
||||
|
||||
4
packages/babel-parser/test/fixtures/typescript/interface/get-set-methods-babel-7/input.ts
vendored
Normal file
4
packages/babel-parser/test/fixtures/typescript/interface/get-set-methods-babel-7/input.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
interface Foo {
|
||||
get(): string;
|
||||
set(): string;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
68
packages/babel-parser/test/fixtures/typescript/interface/get-set-methods-babel-7/output.json
vendored
Normal file
68
packages/babel-parser/test/fixtures/typescript/interface/get-set-methods-babel-7/output.json
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":51,"loc":{"start":{"line":1,"column":14},"end":{"line":4,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":32,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":16}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":18,"end":21,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5},"identifierName":"get"},
|
||||
"name": "get"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":23,"end":31,"loc":{"start":{"line":2,"column":7},"end":{"line":2,"column":15}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":25,"end":31,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":15}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":35,"end":49,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":16}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":35,"end":38,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":5},"identifierName":"set"},
|
||||
"name": "set"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":40,"end":48,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":15}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":42,"end":48,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":15}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/get-set-methods/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/get-set-methods/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -28,8 +28,8 @@
|
||||
"name": "get"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":23,"end":31,"loc":{"start":{"line":2,"column":7},"end":{"line":2,"column":15}},
|
||||
"typeAnnotation": {
|
||||
@ -48,8 +48,8 @@
|
||||
"name": "set"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":40,"end":48,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":15}},
|
||||
"typeAnnotation": {
|
||||
|
||||
@ -48,8 +48,8 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":30,"end":38,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":22}},
|
||||
"typeAnnotation": {
|
||||
@ -83,7 +83,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":53,"end":54,"loc":{"start":{"line":3,"column":13},"end":{"line":3,"column":14},"identifierName":"v"},
|
||||
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/get-set/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/get-set/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -29,8 +29,8 @@
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "get",
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":27,"end":35,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":19}},
|
||||
"typeAnnotation": {
|
||||
@ -49,7 +49,7 @@
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "set",
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":47,"end":48,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":11},"identifierName":"v"},
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
interface Foo {
|
||||
private a();
|
||||
public b();
|
||||
protected c();
|
||||
static d();
|
||||
declare e();
|
||||
abstract f();
|
||||
readonly g();
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":124,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: 'private' modifier cannot appear on a type member. (2:2)",
|
||||
"SyntaxError: 'public' modifier cannot appear on a type member. (3:2)",
|
||||
"SyntaxError: 'protected' modifier cannot appear on a type member. (4:2)",
|
||||
"SyntaxError: 'static' modifier cannot appear on a type member. (5:2)",
|
||||
"SyntaxError: 'declare' modifier cannot appear on a type member. (6:2)",
|
||||
"SyntaxError: 'abstract' modifier cannot appear on a type member. (7:2)",
|
||||
"SyntaxError: 'readonly' modifier can only appear on a property declaration or index signature. (8:2)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":124,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":124,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":13,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":13},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":14,"end":124,"loc":{"start":{"line":1,"column":14},"end":{"line":9,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":30,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":14}},
|
||||
"accessibility": "private",
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":26,"end":27,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":11},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":33,"end":44,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":13}},
|
||||
"accessibility": "public",
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":40,"end":41,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":10},"identifierName":"b"},
|
||||
"name": "b"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":47,"end":61,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":16}},
|
||||
"accessibility": "protected",
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":57,"end":58,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":13},"identifierName":"c"},
|
||||
"name": "c"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":64,"end":75,"loc":{"start":{"line":5,"column":2},"end":{"line":5,"column":13}},
|
||||
"static": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":71,"end":72,"loc":{"start":{"line":5,"column":9},"end":{"line":5,"column":10},"identifierName":"d"},
|
||||
"name": "d"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":78,"end":90,"loc":{"start":{"line":6,"column":2},"end":{"line":6,"column":14}},
|
||||
"declare": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":86,"end":87,"loc":{"start":{"line":6,"column":10},"end":{"line":6,"column":11},"identifierName":"e"},
|
||||
"name": "e"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":93,"end":106,"loc":{"start":{"line":7,"column":2},"end":{"line":7,"column":15}},
|
||||
"abstract": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":102,"end":103,"loc":{"start":{"line":7,"column":11},"end":{"line":7,"column":12},"identifierName":"f"},
|
||||
"name": "f"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":109,"end":122,"loc":{"start":{"line":8,"column":2},"end":{"line":8,"column":15}},
|
||||
"readonly": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":118,"end":119,"loc":{"start":{"line":8,"column":11},"end":{"line":8,"column":12},"identifierName":"g"},
|
||||
"name": "g"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"kind": "method"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -38,7 +38,7 @@
|
||||
"name": "a"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"params": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
@ -51,7 +51,7 @@
|
||||
"name": "b"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"params": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
@ -64,7 +64,7 @@
|
||||
"name": "c"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"params": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
@ -77,7 +77,7 @@
|
||||
"name": "d"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"params": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
@ -90,7 +90,7 @@
|
||||
"name": "e"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"params": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
@ -103,7 +103,7 @@
|
||||
"name": "f"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"params": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
@ -116,7 +116,7 @@
|
||||
"name": "g"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"params": [],
|
||||
"kind": "method"
|
||||
}
|
||||
]
|
||||
|
||||
4
packages/babel-parser/test/fixtures/typescript/interface/method-computed-babel-7/input.ts
vendored
Normal file
4
packages/babel-parser/test/fixtures/typescript/interface/method-computed-babel-7/input.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
interface I {
|
||||
[Symbol.iterator](): void;
|
||||
[Symbol.iterator]?(): number;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
89
packages/babel-parser/test/fixtures/typescript/interface/method-computed-babel-7/output.json
vendored
Normal file
89
packages/babel-parser/test/fixtures/typescript/interface/method-computed-babel-7/output.json
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":80,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":80,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":80,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"I"},
|
||||
"name": "I"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":12,"end":80,"loc":{"start":{"line":1,"column":12},"end":{"line":4,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":44,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":30}},
|
||||
"computed": true,
|
||||
"key": {
|
||||
"type": "MemberExpression",
|
||||
"start":19,"end":34,"loc":{"start":{"line":2,"column":5},"end":{"line":2,"column":20}},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":19,"end":25,"loc":{"start":{"line":2,"column":5},"end":{"line":2,"column":11},"identifierName":"Symbol"},
|
||||
"name": "Symbol"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":26,"end":34,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":20},"identifierName":"iterator"},
|
||||
"name": "iterator"
|
||||
}
|
||||
},
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":37,"end":43,"loc":{"start":{"line":2,"column":23},"end":{"line":2,"column":29}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":39,"end":43,"loc":{"start":{"line":2,"column":25},"end":{"line":2,"column":29}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":49,"end":78,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":33}},
|
||||
"computed": true,
|
||||
"key": {
|
||||
"type": "MemberExpression",
|
||||
"start":50,"end":65,"loc":{"start":{"line":3,"column":5},"end":{"line":3,"column":20}},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":50,"end":56,"loc":{"start":{"line":3,"column":5},"end":{"line":3,"column":11},"identifierName":"Symbol"},
|
||||
"name": "Symbol"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":57,"end":65,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":20},"identifierName":"iterator"},
|
||||
"name": "iterator"
|
||||
}
|
||||
},
|
||||
"optional": true,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":69,"end":77,"loc":{"start":{"line":3,"column":24},"end":{"line":3,"column":32}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start":71,"end":77,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":32}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/method-computed/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/method-computed/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -38,8 +38,8 @@
|
||||
"name": "iterator"
|
||||
}
|
||||
},
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":37,"end":43,"loc":{"start":{"line":2,"column":23},"end":{"line":2,"column":29}},
|
||||
"typeAnnotation": {
|
||||
@ -69,8 +69,8 @@
|
||||
}
|
||||
},
|
||||
"optional": true,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":69,"end":77,"loc":{"start":{"line":3,"column":24},"end":{"line":3,"column":32}},
|
||||
"typeAnnotation": {
|
||||
|
||||
@ -71,8 +71,8 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":55,"end":58,"loc":{"start":{"line":2,"column":41},"end":{"line":2,"column":44}},
|
||||
"typeAnnotation": {
|
||||
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/method-optional-babel-7/input.ts
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/method-optional-babel-7/input.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
interface I {
|
||||
m?(): void;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
49
packages/babel-parser/test/fixtures/typescript/interface/method-optional-babel-7/output.json
vendored
Normal file
49
packages/babel-parser/test/fixtures/typescript/interface/method-optional-babel-7/output.json
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"I"},
|
||||
"name": "I"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":12,"end":31,"loc":{"start":{"line":1,"column":12},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":29,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":15}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":18,"end":19,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":5},"identifierName":"m"},
|
||||
"name": "m"
|
||||
},
|
||||
"computed": false,
|
||||
"optional": true,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":22,"end":28,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":14}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":24,"end":28,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":14}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/method-optional/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/method-optional/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -29,8 +29,8 @@
|
||||
},
|
||||
"computed": false,
|
||||
"optional": true,
|
||||
"parameters": [],
|
||||
"typeAnnotation": {
|
||||
"params": [],
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":22,"end":28,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":14}},
|
||||
"typeAnnotation": {
|
||||
|
||||
4
packages/babel-parser/test/fixtures/typescript/interface/method-plain-babel-7/input.ts
vendored
Normal file
4
packages/babel-parser/test/fixtures/typescript/interface/method-plain-babel-7/input.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
interface I {
|
||||
m();
|
||||
m(x?: number, ...y: number[]): void;
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/method-plain-babel-7/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/method-plain-babel-7/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
96
packages/babel-parser/test/fixtures/typescript/interface/method-plain-babel-7/output.json
vendored
Normal file
96
packages/babel-parser/test/fixtures/typescript/interface/method-plain-babel-7/output.json
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":65,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":65,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":65,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"I"},
|
||||
"name": "I"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":12,"end":65,"loc":{"start":{"line":1,"column":12},"end":{"line":4,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":18,"end":22,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":8}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":18,"end":19,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":5},"identifierName":"m"},
|
||||
"name": "m"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":27,"end":63,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":40}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":27,"end":28,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":5},"identifierName":"m"},
|
||||
"name": "m"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":29,"end":39,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":16},"identifierName":"x"},
|
||||
"name": "x",
|
||||
"optional": true,
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":31,"end":39,"loc":{"start":{"line":3,"column":8},"end":{"line":3,"column":16}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start":33,"end":39,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":16}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":41,"end":55,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":32}},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start":44,"end":45,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":22},"identifierName":"y"},
|
||||
"name": "y"
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":45,"end":55,"loc":{"start":{"line":3,"column":22},"end":{"line":3,"column":32}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSArrayType",
|
||||
"start":47,"end":55,"loc":{"start":{"line":3,"column":24},"end":{"line":3,"column":32}},
|
||||
"elementType": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start":47,"end":53,"loc":{"start":{"line":3,"column":24},"end":{"line":3,"column":30}}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":56,"end":62,"loc":{"start":{"line":3,"column":33},"end":{"line":3,"column":39}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":58,"end":62,"loc":{"start":{"line":3,"column":35},"end":{"line":3,"column":39}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/method-plain/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/method-plain/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -28,7 +28,7 @@
|
||||
"name": "m"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [],
|
||||
"params": [],
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
@ -40,7 +40,7 @@
|
||||
"name": "m"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":29,"end":39,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":16},"identifierName":"x"},
|
||||
@ -77,7 +77,7 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":56,"end":62,"loc":{"start":{"line":3,"column":33},"end":{"line":3,"column":39}},
|
||||
"typeAnnotation": {
|
||||
|
||||
5
packages/babel-parser/test/fixtures/typescript/interface/pattern-parameters-babel-7/input.ts
vendored
Normal file
5
packages/babel-parser/test/fixtures/typescript/interface/pattern-parameters-babel-7/input.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
interface A {
|
||||
foo([]?): void;
|
||||
bar({}, []?): any;
|
||||
baz(a: string, b: number, []?): void;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": false
|
||||
}
|
||||
140
packages/babel-parser/test/fixtures/typescript/interface/pattern-parameters-babel-7/output.json
vendored
Normal file
140
packages/babel-parser/test/fixtures/typescript/interface/pattern-parameters-babel-7/output.json
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TSInterfaceDeclaration",
|
||||
"start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"A"},
|
||||
"name": "A"
|
||||
},
|
||||
"body": {
|
||||
"type": "TSInterfaceBody",
|
||||
"start":12,"end":94,"loc":{"start":{"line":1,"column":12},"end":{"line":5,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":16,"end":31,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":17}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":16,"end":19,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":20,"end":23,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9}},
|
||||
"elements": [],
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":24,"end":30,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":16}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":26,"end":30,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":16}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":34,"end":52,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":20}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":34,"end":37,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":5},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "ObjectPattern",
|
||||
"start":38,"end":40,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":8}},
|
||||
"properties": []
|
||||
},
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":42,"end":45,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":13}},
|
||||
"elements": [],
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":46,"end":51,"loc":{"start":{"line":3,"column":14},"end":{"line":3,"column":19}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSAnyKeyword",
|
||||
"start":48,"end":51,"loc":{"start":{"line":3,"column":16},"end":{"line":3,"column":19}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
},
|
||||
{
|
||||
"type": "TSMethodSignature",
|
||||
"start":55,"end":92,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":39}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":55,"end":58,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":5},"identifierName":"baz"},
|
||||
"name": "baz"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":59,"end":68,"loc":{"start":{"line":4,"column":6},"end":{"line":4,"column":15},"identifierName":"a"},
|
||||
"name": "a",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":60,"end":68,"loc":{"start":{"line":4,"column":7},"end":{"line":4,"column":15}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSStringKeyword",
|
||||
"start":62,"end":68,"loc":{"start":{"line":4,"column":9},"end":{"line":4,"column":15}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":70,"end":79,"loc":{"start":{"line":4,"column":17},"end":{"line":4,"column":26},"identifierName":"b"},
|
||||
"name": "b",
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":71,"end":79,"loc":{"start":{"line":4,"column":18},"end":{"line":4,"column":26}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSNumberKeyword",
|
||||
"start":73,"end":79,"loc":{"start":{"line":4,"column":20},"end":{"line":4,"column":26}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":81,"end":84,"loc":{"start":{"line":4,"column":28},"end":{"line":4,"column":31}},
|
||||
"elements": [],
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":85,"end":91,"loc":{"start":{"line":4,"column":32},"end":{"line":4,"column":38}},
|
||||
"typeAnnotation": {
|
||||
"type": "TSVoidKeyword",
|
||||
"start":87,"end":91,"loc":{"start":{"line":4,"column":34},"end":{"line":4,"column":38}}
|
||||
}
|
||||
},
|
||||
"kind": "method"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/typescript/interface/pattern-parameters/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/typescript/interface/pattern-parameters/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"BABEL_8_BREAKING": true
|
||||
}
|
||||
@ -28,7 +28,7 @@
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "ArrayPattern",
|
||||
"start":20,"end":23,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9}},
|
||||
@ -36,7 +36,7 @@
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":24,"end":30,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":16}},
|
||||
"typeAnnotation": {
|
||||
@ -55,7 +55,7 @@
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "ObjectPattern",
|
||||
"start":38,"end":40,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":8}},
|
||||
@ -68,7 +68,7 @@
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":46,"end":51,"loc":{"start":{"line":3,"column":14},"end":{"line":3,"column":19}},
|
||||
"typeAnnotation": {
|
||||
@ -87,7 +87,7 @@
|
||||
"name": "baz"
|
||||
},
|
||||
"computed": false,
|
||||
"parameters": [
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":59,"end":68,"loc":{"start":{"line":4,"column":6},"end":{"line":4,"column":15},"identifierName":"a"},
|
||||
@ -121,7 +121,7 @@
|
||||
"optional": true
|
||||
}
|
||||
],
|
||||
"typeAnnotation": {
|
||||
"returnType": {
|
||||
"type": "TSTypeAnnotation",
|
||||
"start":85,"end":91,"loc":{"start":{"line":4,"column":32},"end":{"line":4,"column":38}},
|
||||
"typeAnnotation": {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user