Support Flow this parameter annotations (#12234)
This commit is contained in:
parent
407e8b5c7b
commit
16e9f1c8e5
@ -289,6 +289,18 @@ export function FunctionTypeAnnotation(
|
||||
) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.token("(");
|
||||
|
||||
if (node.this) {
|
||||
this.word("this");
|
||||
this.token(":");
|
||||
this.space();
|
||||
this.print(node.this.typeAnnotation, node);
|
||||
if (node.params.length || node.rest) {
|
||||
this.token(",");
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
|
||||
this.printList(node.params, node);
|
||||
|
||||
if (node.rest) {
|
||||
|
||||
45
packages/babel-generator/test/fixtures/flow/this-param/input.js
vendored
Normal file
45
packages/babel-generator/test/fixtures/flow/this-param/input.js
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
function one (this : number) {}
|
||||
function two (this : number, a) {}
|
||||
function three (this : number, ...a) {}
|
||||
function four (this : number, a, b, ...c) {}
|
||||
function five<T> (this : T) {}
|
||||
|
||||
type six = (this : number) => void
|
||||
type seven = (this : number, a : number) => void
|
||||
type eight = (this : number, ...a : any) => void
|
||||
type nine = <T>(this : T) => void
|
||||
|
||||
type ten = {
|
||||
m1(this : string) : void,
|
||||
m2(this : string, a : number) : void,
|
||||
m3(this : string, ...a : any) : void,
|
||||
m4<T>(this : T) : void
|
||||
}
|
||||
|
||||
declare function eleven (this : number) : void
|
||||
declare function twelve (this : string, a : number) : void
|
||||
declare function thirteen (this : string, ...a : any) : void
|
||||
declare function fourteen<T>(this : T) : void
|
||||
|
||||
declare class Fifteen {
|
||||
m1(this : string) : void,
|
||||
m2(this : string, a : number) : void,
|
||||
m3(this : string, ...a : any) : void,
|
||||
m4<T>(this : T) : void
|
||||
}
|
||||
|
||||
class Sixteen {
|
||||
m1 (this : number) {}
|
||||
m2 (this : number, a) {}
|
||||
m3 (this : number, ...a) {}
|
||||
m4 (this : number, a, b, ...c) {}
|
||||
m5<T> (this : T) {}
|
||||
}
|
||||
|
||||
let seventeen = {
|
||||
m1 (this : number) {},
|
||||
m2 (this : number, a) {},
|
||||
m3 (this : number, ...a) {},
|
||||
m4 (this : number, a, b, ...c) {},
|
||||
m5<T> (this : T) {}
|
||||
}
|
||||
56
packages/babel-generator/test/fixtures/flow/this-param/output.js
vendored
Normal file
56
packages/babel-generator/test/fixtures/flow/this-param/output.js
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
function one(this: number) {}
|
||||
|
||||
function two(this: number, a) {}
|
||||
|
||||
function three(this: number, ...a) {}
|
||||
|
||||
function four(this: number, a, b, ...c) {}
|
||||
|
||||
function five<T>(this: T) {}
|
||||
|
||||
type six = (this: number) => void;
|
||||
type seven = (this: number, a: number) => void;
|
||||
type eight = (this: number, ...a: any) => void;
|
||||
type nine = <T>(this: T) => void;
|
||||
type ten = {
|
||||
m1(this: string): void,
|
||||
m2(this: string, a: number): void,
|
||||
m3(this: string, ...a: any): void,
|
||||
m4<T>(this: T): void,
|
||||
};
|
||||
declare function eleven(this: number): void;
|
||||
declare function twelve(this: string, a: number): void;
|
||||
declare function thirteen(this: string, ...a: any): void;
|
||||
declare function fourteen<T>(this: T): void;
|
||||
declare class Fifteen {
|
||||
m1(this: string): void,
|
||||
m2(this: string, a: number): void,
|
||||
m3(this: string, ...a: any): void,
|
||||
m4<T>(this: T): void,
|
||||
}
|
||||
|
||||
class Sixteen {
|
||||
m1(this: number) {}
|
||||
|
||||
m2(this: number, a) {}
|
||||
|
||||
m3(this: number, ...a) {}
|
||||
|
||||
m4(this: number, a, b, ...c) {}
|
||||
|
||||
m5<T>(this: T) {}
|
||||
|
||||
}
|
||||
|
||||
let seventeen = {
|
||||
m1(this: number) {},
|
||||
|
||||
m2(this: number, a) {},
|
||||
|
||||
m3(this: number, ...a) {},
|
||||
|
||||
m4(this: number, a, b, ...c) {},
|
||||
|
||||
m5<T>(this: T) {}
|
||||
|
||||
};
|
||||
@ -81,6 +81,7 @@ const FlowErrors = Object.freeze({
|
||||
"Number enum members need to be initialized, e.g. `%1 = 1` in enum `%0`.",
|
||||
EnumStringMemberInconsistentlyInitailized:
|
||||
"String enum members need to consistently either all use initializers, or use no initializers, in enum `%0`.",
|
||||
GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.",
|
||||
ImportTypeShorthandOnlyInPureImport:
|
||||
"The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements",
|
||||
InexactInsideExact:
|
||||
@ -97,7 +98,16 @@ const FlowErrors = Object.freeze({
|
||||
NestedFlowComment: "Cannot have a flow comment inside another flow comment",
|
||||
OptionalBindingPattern:
|
||||
"A binding pattern parameter cannot be optional in an implementation signature.",
|
||||
SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.",
|
||||
SpreadVariance: "Spread properties cannot have variance",
|
||||
ThisParamAnnotationRequired:
|
||||
"A type annotation is required for the `this` parameter.",
|
||||
ThisParamBannedInConstructor:
|
||||
"Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",
|
||||
ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.",
|
||||
ThisParamMustBeFirst:
|
||||
"The `this` parameter must be the first function parameter.",
|
||||
ThisParamNoDefault: "The `this` parameter may not have a default value.",
|
||||
TypeBeforeInitializer:
|
||||
"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`",
|
||||
TypeCastInPattern:
|
||||
@ -308,6 +318,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const tmp = this.flowParseFunctionTypeParams();
|
||||
typeNode.params = tmp.params;
|
||||
typeNode.rest = tmp.rest;
|
||||
typeNode.this = tmp._this;
|
||||
this.expect(tt.parenR);
|
||||
|
||||
[
|
||||
@ -905,21 +916,30 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.params = [];
|
||||
node.rest = null;
|
||||
node.typeParameters = null;
|
||||
node.this = null;
|
||||
|
||||
if (this.isRelational("<")) {
|
||||
node.typeParameters = this.flowParseTypeParameterDeclaration();
|
||||
}
|
||||
|
||||
this.expect(tt.parenL);
|
||||
if (this.match(tt._this)) {
|
||||
node.this = this.flowParseFunctionTypeParam(/* first */ true);
|
||||
// match Flow parser behavior
|
||||
node.this.name = null;
|
||||
if (!this.match(tt.parenR)) {
|
||||
this.expect(tt.comma);
|
||||
}
|
||||
}
|
||||
while (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {
|
||||
node.params.push(this.flowParseFunctionTypeParam());
|
||||
node.params.push(this.flowParseFunctionTypeParam(false));
|
||||
if (!this.match(tt.parenR)) {
|
||||
this.expect(tt.comma);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.eat(tt.ellipsis)) {
|
||||
node.rest = this.flowParseFunctionTypeParam();
|
||||
node.rest = this.flowParseFunctionTypeParam(false);
|
||||
}
|
||||
this.expect(tt.parenR);
|
||||
node.returnType = this.flowParseTypeInitialiser();
|
||||
@ -1162,6 +1182,17 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
if (kind === "get" || kind === "set") {
|
||||
this.flowCheckGetterSetterParams(node);
|
||||
}
|
||||
/** Declared classes/interfaces do not allow spread */
|
||||
if (
|
||||
!allowSpread &&
|
||||
node.key.name === "constructor" &&
|
||||
node.value.this
|
||||
) {
|
||||
this.raise(
|
||||
node.value.this.start,
|
||||
FlowErrors.ThisParamBannedInConstructor,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (kind !== "init") this.unexpected();
|
||||
|
||||
@ -1189,6 +1220,16 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const start = property.start;
|
||||
const length =
|
||||
property.value.params.length + (property.value.rest ? 1 : 0);
|
||||
|
||||
if (property.value.this) {
|
||||
this.raise(
|
||||
property.value.this.start,
|
||||
property.kind === "get"
|
||||
? FlowErrors.GetterMayNotHaveThisParam
|
||||
: FlowErrors.SetterMayNotHaveThisParam,
|
||||
);
|
||||
}
|
||||
|
||||
if (length !== paramCount) {
|
||||
if (property.kind === "get") {
|
||||
this.raise(start, Errors.BadGetterArity);
|
||||
@ -1270,16 +1311,24 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return this.finishNode(node, "TupleTypeAnnotation");
|
||||
}
|
||||
|
||||
flowParseFunctionTypeParam(): N.FlowFunctionTypeParam {
|
||||
flowParseFunctionTypeParam(first: boolean): N.FlowFunctionTypeParam {
|
||||
let name = null;
|
||||
let optional = false;
|
||||
let typeAnnotation = null;
|
||||
const node = this.startNode();
|
||||
const lh = this.lookahead();
|
||||
const isThis = this.state.type === tt._this;
|
||||
|
||||
if (lh.type === tt.colon || lh.type === tt.question) {
|
||||
name = this.parseIdentifier();
|
||||
if (isThis && !first) {
|
||||
this.raise(node.start, FlowErrors.ThisParamMustBeFirst);
|
||||
}
|
||||
name = this.parseIdentifier(isThis);
|
||||
if (this.eat(tt.question)) {
|
||||
optional = true;
|
||||
if (isThis) {
|
||||
this.raise(node.start, FlowErrors.ThisParamMayNotBeOptional);
|
||||
}
|
||||
}
|
||||
typeAnnotation = this.flowParseTypeInitialiser();
|
||||
} else {
|
||||
@ -1303,18 +1352,31 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
flowParseFunctionTypeParams(
|
||||
params: N.FlowFunctionTypeParam[] = [],
|
||||
): { params: N.FlowFunctionTypeParam[], rest: ?N.FlowFunctionTypeParam } {
|
||||
): {
|
||||
params: N.FlowFunctionTypeParam[],
|
||||
rest: ?N.FlowFunctionTypeParam,
|
||||
_this: ?N.FlowFunctionTypeParam,
|
||||
} {
|
||||
let rest: ?N.FlowFunctionTypeParam = null;
|
||||
let _this: ?N.FlowFunctionTypeParam = null;
|
||||
if (this.match(tt._this)) {
|
||||
_this = this.flowParseFunctionTypeParam(/* first */ true);
|
||||
// match Flow parser behavior
|
||||
_this.name = null;
|
||||
if (!this.match(tt.parenR)) {
|
||||
this.expect(tt.comma);
|
||||
}
|
||||
}
|
||||
while (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {
|
||||
params.push(this.flowParseFunctionTypeParam());
|
||||
params.push(this.flowParseFunctionTypeParam(false));
|
||||
if (!this.match(tt.parenR)) {
|
||||
this.expect(tt.comma);
|
||||
}
|
||||
}
|
||||
if (this.eat(tt.ellipsis)) {
|
||||
rest = this.flowParseFunctionTypeParam();
|
||||
rest = this.flowParseFunctionTypeParam(false);
|
||||
}
|
||||
return { params, rest };
|
||||
return { params, rest, _this };
|
||||
}
|
||||
|
||||
flowIdentToTypeAnnotation(
|
||||
@ -1408,6 +1470,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
tmp = this.flowParseFunctionTypeParams();
|
||||
node.params = tmp.params;
|
||||
node.rest = tmp.rest;
|
||||
node.this = tmp._this;
|
||||
this.expect(tt.parenR);
|
||||
|
||||
this.expect(tt.arrow);
|
||||
@ -1423,7 +1486,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
// Check to see if this is actually a grouped type
|
||||
if (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {
|
||||
if (this.match(tt.name)) {
|
||||
if (this.match(tt.name) || this.match(tt._this)) {
|
||||
const token = this.lookahead().type;
|
||||
isGroupedType = token !== tt.question && token !== tt.colon;
|
||||
} else {
|
||||
@ -1462,6 +1525,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
|
||||
node.params = tmp.params;
|
||||
node.rest = tmp.rest;
|
||||
node.this = tmp._this;
|
||||
|
||||
this.expect(tt.parenR);
|
||||
|
||||
@ -2311,6 +2375,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return !this.match(tt.colon) && super.isNonstaticConstructor(method);
|
||||
}
|
||||
|
||||
// determine whether a parameter is a this param
|
||||
isThisParam(param) {
|
||||
return param.type === "Identifier" && param.name === "this";
|
||||
}
|
||||
|
||||
// parse type parameters for class methods
|
||||
pushClassMethod(
|
||||
classBody: N.ClassBody,
|
||||
@ -2336,6 +2405,24 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
isConstructor,
|
||||
allowsDirectSuper,
|
||||
);
|
||||
|
||||
if (method.params && isConstructor) {
|
||||
const params = method.params;
|
||||
if (params.length > 0 && this.isThisParam(params[0])) {
|
||||
this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);
|
||||
}
|
||||
// estree support
|
||||
} else if (
|
||||
// $FlowFixMe flow does not know about the face that estree can replace ClassMethod with MethodDefinition
|
||||
method.type === "MethodDefinition" &&
|
||||
isConstructor &&
|
||||
method.value.params
|
||||
) {
|
||||
const params = method.value.params;
|
||||
if (params.length > 0 && this.isThisParam(params[0])) {
|
||||
this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pushClassPrivateMethod(
|
||||
@ -2377,6 +2464,19 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
|
||||
checkGetterSetterParams(method: N.ObjectMethod | N.ClassMethod): void {
|
||||
super.checkGetterSetterParams(method);
|
||||
const params = this.getObjectOrClassMethodParams(method);
|
||||
if (params.length > 0) {
|
||||
const param = params[0];
|
||||
if (this.isThisParam(param) && method.kind === "get") {
|
||||
this.raise(param.start, FlowErrors.GetterMayNotHaveThisParam);
|
||||
} else if (this.isThisParam(param)) {
|
||||
this.raise(param.start, FlowErrors.SetterMayNotHaveThisParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parsePropertyName(
|
||||
node: N.ObjectOrClassMember | N.ClassMember | N.TsNamedTypeElementBase,
|
||||
isPrivateNameAllowed: boolean,
|
||||
@ -2434,12 +2534,22 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
if (param.type !== "Identifier") {
|
||||
this.raise(param.start, FlowErrors.OptionalBindingPattern);
|
||||
}
|
||||
if (this.isThisParam(param)) {
|
||||
this.raise(param.start, FlowErrors.ThisParamMayNotBeOptional);
|
||||
}
|
||||
|
||||
((param: any): N.Identifier).optional = true;
|
||||
}
|
||||
if (this.match(tt.colon)) {
|
||||
param.typeAnnotation = this.flowParseTypeAnnotation();
|
||||
} else if (this.isThisParam(param)) {
|
||||
this.raise(param.start, FlowErrors.ThisParamAnnotationRequired);
|
||||
}
|
||||
|
||||
if (this.match(tt.eq) && this.isThisParam(param)) {
|
||||
this.raise(param.start, FlowErrors.ThisParamNoDefault);
|
||||
}
|
||||
|
||||
this.resetEndLocation(param);
|
||||
return param;
|
||||
}
|
||||
@ -2609,6 +2719,16 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
|
||||
}
|
||||
|
||||
parseBindingAtom(): N.Pattern {
|
||||
switch (this.state.type) {
|
||||
case tt._this:
|
||||
// "this" may be the name of a parameter, so allow it.
|
||||
return this.parseIdentifier(/* liberal */ true);
|
||||
default:
|
||||
return super.parseBindingAtom();
|
||||
}
|
||||
}
|
||||
|
||||
// parse function type parameters - function foo<T>() {}
|
||||
parseFunctionParams(node: N.Function, allowModifiers?: boolean): void {
|
||||
// $FlowFixMe
|
||||
@ -2866,6 +2986,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return;
|
||||
}
|
||||
|
||||
// ensure the `this` param is first, if it exists
|
||||
for (let i = 0; i < node.params.length; i++) {
|
||||
if (this.isThisParam(node.params[i]) && i > 0) {
|
||||
this.raise(node.params[i].start, FlowErrors.ThisParamMustBeFirst);
|
||||
}
|
||||
}
|
||||
|
||||
return super.checkParams(...arguments);
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,10 @@
|
||||
"expression": {
|
||||
"type": "ObjectExpression",
|
||||
"start":1,"end":14,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":14}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "Property",
|
||||
@ -44,11 +48,7 @@
|
||||
},
|
||||
"shorthand": false
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":32,"end":38,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":38}}
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":27,"end":33,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":33}}
|
||||
|
||||
@ -49,6 +49,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":30,"end":36,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":36}}
|
||||
|
||||
@ -48,6 +48,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":41,"end":45,"loc":{"start":{"line":1,"column":41},"end":{"line":1,"column":45}}
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":21,"end":25,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":25}}
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":22,"end":26,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":26}}
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":28,"end":32,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":32}}
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":29,"end":33,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":33}}
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":32,"end":36,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":36}}
|
||||
|
||||
@ -45,6 +45,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":31,"end":35,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":35}}
|
||||
|
||||
@ -71,6 +71,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":46,"end":50,"loc":{"start":{"line":1,"column":46},"end":{"line":1,"column":50}}
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberLiteralTypeAnnotation",
|
||||
"start":28,"end":31,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":31}},
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberLiteralTypeAnnotation",
|
||||
"start":26,"end":29,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":29}},
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
"start":7,"end":21,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":21}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "ArrayTypeAnnotation",
|
||||
"start":13,"end":21,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":21}},
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
"start":8,"end":20,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":20}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":14,"end":20,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":20}}
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":14,"end":20,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":20}}
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":14,"end":20,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":20}}
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":14,"end":20,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":20}}
|
||||
@ -66,6 +67,7 @@
|
||||
],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":46,"end":52,"loc":{"start":{"line":1,"column":46},"end":{"line":1,"column":52}}
|
||||
|
||||
@ -67,6 +67,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":21,"end":27,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":27}}
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":18,"end":24,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":24}}
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":29,"end":35,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":17}}
|
||||
@ -82,6 +83,7 @@
|
||||
],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":57,"end":61,"loc":{"start":{"line":3,"column":20},"end":{"line":3,"column":24}}
|
||||
@ -111,6 +113,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":76,"end":82,"loc":{"start":{"line":4,"column":13},"end":{"line":4,"column":19}}
|
||||
@ -155,6 +158,7 @@
|
||||
],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":106,"end":110,"loc":{"start":{"line":5,"column":22},"end":{"line":5,"column":26}}
|
||||
@ -184,6 +188,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":123,"end":129,"loc":{"start":{"line":6,"column":11},"end":{"line":6,"column":17}}
|
||||
@ -228,6 +233,7 @@
|
||||
],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":151,"end":155,"loc":{"start":{"line":7,"column":20},"end":{"line":7,"column":24}}
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
"start":27,"end":37,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":25}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "ThisTypeAnnotation",
|
||||
"start":33,"end":37,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":25}}
|
||||
|
||||
@ -76,6 +76,7 @@
|
||||
],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":68,"end":72,"loc":{"start":{"line":1,"column":68},"end":{"line":1,"column":72}}
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":37,"end":43,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":43}}
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":49,"end":55,"loc":{"start":{"line":1,"column":49},"end":{"line":1,"column":55}}
|
||||
|
||||
@ -57,6 +57,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":64,"end":70,"loc":{"start":{"line":1,"column":64},"end":{"line":1,"column":70}}
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":33,"end":39,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":39}}
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":43,"end":49,"loc":{"start":{"line":1,"column":43},"end":{"line":1,"column":49}}
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":44,"end":50,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":50}}
|
||||
|
||||
@ -48,6 +48,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":52,"end":58,"loc":{"start":{"line":1,"column":52},"end":{"line":1,"column":58}}
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":32,"end":38,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":38}}
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":30,"end":36,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":36}}
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":30,"end":36,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":36}}
|
||||
@ -72,6 +73,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":62,"end":68,"loc":{"start":{"line":2,"column":23},"end":{"line":2,"column":29}}
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":24,"end":28,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":28}}
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":24,"end":28,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":28}}
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":27,"end":31,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":31}}
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":44,"end":48,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":48}}
|
||||
|
||||
@ -77,6 +77,7 @@
|
||||
],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":67,"end":71,"loc":{"start":{"line":1,"column":67},"end":{"line":1,"column":71}}
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":31,"end":37,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":37}}
|
||||
|
||||
@ -61,6 +61,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":44,"end":48,"loc":{"start":{"line":3,"column":13},"end":{"line":3,"column":17}}
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
"start":19,"end":31,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":31}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":25,"end":31,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":31}}
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":24,"end":30,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":30}}
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":25,"end":26,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":26}},
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":22,"end":23,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":23}},
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":34,"end":48,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":30}},
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":39,"end":53,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":35}},
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
"start":30,"end":42,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":42}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":36,"end":42,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":42}}
|
||||
@ -70,6 +71,10 @@
|
||||
"argument": {
|
||||
"type": "TypeCastExpression",
|
||||
"start":57,"end":63,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":16}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 56
|
||||
},
|
||||
"expression": {
|
||||
"type": "NumericLiteral",
|
||||
"start":57,"end":58,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":11}},
|
||||
@ -86,10 +91,6 @@
|
||||
"type": "AnyTypeAnnotation",
|
||||
"start":60,"end":63,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":16}}
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 56
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
"start":35,"end":47,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":47}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":41,"end":47,"loc":{"start":{"line":1,"column":41},"end":{"line":1,"column":47}}
|
||||
@ -70,6 +71,10 @@
|
||||
"argument": {
|
||||
"type": "TypeCastExpression",
|
||||
"start":62,"end":68,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":16}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 61
|
||||
},
|
||||
"expression": {
|
||||
"type": "NumericLiteral",
|
||||
"start":62,"end":63,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":11}},
|
||||
@ -86,10 +91,6 @@
|
||||
"type": "AnyTypeAnnotation",
|
||||
"start":65,"end":68,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":16}}
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 61
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":30,"end":44,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":30}},
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":35,"end":49,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":35}},
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":23,"end":27,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":27}}
|
||||
@ -48,6 +49,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":51,"end":55,"loc":{"start":{"line":2,"column":23},"end":{"line":2,"column":27}}
|
||||
|
||||
@ -66,6 +66,7 @@
|
||||
],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":25,"end":29,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":29}}
|
||||
|
||||
@ -57,6 +57,7 @@
|
||||
}
|
||||
},
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":28,"end":34,"loc":{"start":{"line":2,"column":17},"end":{"line":2,"column":23}}
|
||||
|
||||
@ -57,6 +57,7 @@
|
||||
],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":32,"end":38,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":27}}
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":22,"end":26,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":15}}
|
||||
|
||||
@ -57,6 +57,7 @@
|
||||
}
|
||||
},
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":26,"end":30,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":19}}
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "BooleanTypeAnnotation",
|
||||
"start":32,"end":39,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":39}}
|
||||
|
||||
@ -124,6 +124,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":64,"end":85,"loc":{"start":{"line":1,"column":64},"end":{"line":1,"column":85}},
|
||||
|
||||
@ -63,6 +63,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":33,"end":37,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":37}}
|
||||
@ -155,6 +156,7 @@
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":93,"end":97,"loc":{"start":{"line":2,"column":35},"end":{"line":2,"column":39}}
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":24,"end":28,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":28}}
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":22,"end":26,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":26}}
|
||||
@ -48,6 +49,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":50,"end":54,"loc":{"start":{"line":2,"column":22},"end":{"line":2,"column":26}}
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":22,"end":26,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":26}}
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":22,"end":26,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":26}}
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":38,"end":42,"loc":{"start":{"line":2,"column":22},"end":{"line":2,"column":26}}
|
||||
|
||||
7
packages/babel-parser/test/fixtures/flow/this-annotation/declare-function/input.js
vendored
Normal file
7
packages/babel-parser/test/fixtures/flow/this-annotation/declare-function/input.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
declare function foo (this : number, a : string, b : number) : void
|
||||
|
||||
declare function bar (this : number): void
|
||||
|
||||
declare function baz (this : number, ...a : any): void
|
||||
|
||||
declare function qux<T> (this : T) : void
|
||||
212
packages/babel-parser/test/fixtures/flow/this-annotation/declare-function/output.json
vendored
Normal file
212
packages/babel-parser/test/fixtures/flow/this-annotation/declare-function/output.json
vendored
Normal file
@ -0,0 +1,212 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":210,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":41}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":210,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":41}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareFunction",
|
||||
"start":0,"end":67,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":67}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":17,"end":67,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":67},"identifierName":"foo"},
|
||||
"name": "foo",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":21,"end":67,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":67}},
|
||||
"typeAnnotation": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":21,"end":67,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":67}},
|
||||
"typeParameters": null,
|
||||
"params": [
|
||||
{
|
||||
"type": "FunctionTypeParam",
|
||||
"start":37,"end":47,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":47}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":37,"end":38,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":38},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":41,"end":47,"loc":{"start":{"line":1,"column":41},"end":{"line":1,"column":47}}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FunctionTypeParam",
|
||||
"start":49,"end":59,"loc":{"start":{"line":1,"column":49},"end":{"line":1,"column":59}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":49,"end":50,"loc":{"start":{"line":1,"column":49},"end":{"line":1,"column":50},"identifierName":"b"},
|
||||
"name": "b"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":53,"end":59,"loc":{"start":{"line":1,"column":53},"end":{"line":1,"column":59}}
|
||||
}
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":22,"end":35,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":35}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":29,"end":35,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":35}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":63,"end":67,"loc":{"start":{"line":1,"column":63},"end":{"line":1,"column":67}}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"predicate": null
|
||||
},
|
||||
{
|
||||
"type": "DeclareFunction",
|
||||
"start":69,"end":111,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":42}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":86,"end":111,"loc":{"start":{"line":3,"column":17},"end":{"line":3,"column":42},"identifierName":"bar"},
|
||||
"name": "bar",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":90,"end":111,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":42}},
|
||||
"typeAnnotation": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":90,"end":111,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":42}},
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":91,"end":104,"loc":{"start":{"line":3,"column":22},"end":{"line":3,"column":35}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":98,"end":104,"loc":{"start":{"line":3,"column":29},"end":{"line":3,"column":35}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":107,"end":111,"loc":{"start":{"line":3,"column":38},"end":{"line":3,"column":42}}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"predicate": null
|
||||
},
|
||||
{
|
||||
"type": "DeclareFunction",
|
||||
"start":113,"end":167,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":54}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":130,"end":167,"loc":{"start":{"line":5,"column":17},"end":{"line":5,"column":54},"identifierName":"baz"},
|
||||
"name": "baz",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":134,"end":167,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":54}},
|
||||
"typeAnnotation": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":134,"end":167,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":54}},
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":153,"end":160,"loc":{"start":{"line":5,"column":40},"end":{"line":5,"column":47}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":153,"end":154,"loc":{"start":{"line":5,"column":40},"end":{"line":5,"column":41},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "AnyTypeAnnotation",
|
||||
"start":157,"end":160,"loc":{"start":{"line":5,"column":44},"end":{"line":5,"column":47}}
|
||||
}
|
||||
},
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":135,"end":148,"loc":{"start":{"line":5,"column":22},"end":{"line":5,"column":35}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":142,"end":148,"loc":{"start":{"line":5,"column":29},"end":{"line":5,"column":35}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":163,"end":167,"loc":{"start":{"line":5,"column":50},"end":{"line":5,"column":54}}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"predicate": null
|
||||
},
|
||||
{
|
||||
"type": "DeclareFunction",
|
||||
"start":169,"end":210,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":41}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":186,"end":210,"loc":{"start":{"line":7,"column":17},"end":{"line":7,"column":41},"identifierName":"qux"},
|
||||
"name": "qux",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":189,"end":210,"loc":{"start":{"line":7,"column":20},"end":{"line":7,"column":41}},
|
||||
"typeAnnotation": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":189,"end":210,"loc":{"start":{"line":7,"column":20},"end":{"line":7,"column":41}},
|
||||
"typeParameters": {
|
||||
"type": "TypeParameterDeclaration",
|
||||
"start":189,"end":192,"loc":{"start":{"line":7,"column":20},"end":{"line":7,"column":23}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TypeParameter",
|
||||
"start":190,"end":191,"loc":{"start":{"line":7,"column":21},"end":{"line":7,"column":22}},
|
||||
"name": "T",
|
||||
"variance": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":194,"end":202,"loc":{"start":{"line":7,"column":25},"end":{"line":7,"column":33}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":201,"end":202,"loc":{"start":{"line":7,"column":32},"end":{"line":7,"column":33}},
|
||||
"typeParameters": null,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":201,"end":202,"loc":{"start":{"line":7,"column":32},"end":{"line":7,"column":33},"identifierName":"T"},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":206,"end":210,"loc":{"start":{"line":7,"column":37},"end":{"line":7,"column":41}}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"predicate": null
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
6
packages/babel-parser/test/fixtures/flow/this-annotation/declare-method/input.js
vendored
Normal file
6
packages/babel-parser/test/fixtures/flow/this-annotation/declare-method/input.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
declare class A {
|
||||
m(this : number, a : number, b : string) : void,
|
||||
n(this : number, ...c : any) : void,
|
||||
o(this : number) : void,
|
||||
p<T>(this : T) : void
|
||||
}
|
||||
235
packages/babel-parser/test/fixtures/flow/this-annotation/declare-method/output.json
vendored
Normal file
235
packages/babel-parser/test/fixtures/flow/this-annotation/declare-method/output.json
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":168,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":168,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareClass",
|
||||
"start":0,"end":168,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"A"},
|
||||
"name": "A"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start":16,"end":168,"loc":{"start":{"line":1,"column":16},"end":{"line":6,"column":1}},
|
||||
"callProperties": [],
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start":22,"end":69,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":51}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":23,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":5},"identifierName":"m"},
|
||||
"name": "m"
|
||||
},
|
||||
"static": false,
|
||||
"proto": false,
|
||||
"kind": "init",
|
||||
"method": true,
|
||||
"value": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":22,"end":69,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":51}},
|
||||
"params": [
|
||||
{
|
||||
"type": "FunctionTypeParam",
|
||||
"start":39,"end":49,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":31}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":39,"end":40,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":22},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":43,"end":49,"loc":{"start":{"line":2,"column":25},"end":{"line":2,"column":31}}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FunctionTypeParam",
|
||||
"start":51,"end":61,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":43}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":51,"end":52,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34},"identifierName":"b"},
|
||||
"name": "b"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":55,"end":61,"loc":{"start":{"line":2,"column":37},"end":{"line":2,"column":43}}
|
||||
}
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":24,"end":37,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":19}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":31,"end":37,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":19}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":65,"end":69,"loc":{"start":{"line":2,"column":47},"end":{"line":2,"column":51}}
|
||||
}
|
||||
},
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start":75,"end":110,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":39}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":75,"end":76,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":5},"identifierName":"n"},
|
||||
"name": "n"
|
||||
},
|
||||
"static": false,
|
||||
"proto": false,
|
||||
"kind": "init",
|
||||
"method": true,
|
||||
"value": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":75,"end":110,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":39}},
|
||||
"params": [],
|
||||
"rest": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":95,"end":102,"loc":{"start":{"line":3,"column":24},"end":{"line":3,"column":31}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":95,"end":96,"loc":{"start":{"line":3,"column":24},"end":{"line":3,"column":25},"identifierName":"c"},
|
||||
"name": "c"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "AnyTypeAnnotation",
|
||||
"start":99,"end":102,"loc":{"start":{"line":3,"column":28},"end":{"line":3,"column":31}}
|
||||
}
|
||||
},
|
||||
"typeParameters": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":77,"end":90,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":19}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":84,"end":90,"loc":{"start":{"line":3,"column":13},"end":{"line":3,"column":19}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":106,"end":110,"loc":{"start":{"line":3,"column":35},"end":{"line":3,"column":39}}
|
||||
}
|
||||
},
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start":116,"end":139,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":27}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":116,"end":117,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":5},"identifierName":"o"},
|
||||
"name": "o"
|
||||
},
|
||||
"static": false,
|
||||
"proto": false,
|
||||
"kind": "init",
|
||||
"method": true,
|
||||
"value": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":116,"end":139,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":27}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":118,"end":131,"loc":{"start":{"line":4,"column":6},"end":{"line":4,"column":19}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":125,"end":131,"loc":{"start":{"line":4,"column":13},"end":{"line":4,"column":19}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":135,"end":139,"loc":{"start":{"line":4,"column":23},"end":{"line":4,"column":27}}
|
||||
}
|
||||
},
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start":145,"end":166,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":25}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":145,"end":146,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":5},"identifierName":"p"},
|
||||
"name": "p"
|
||||
},
|
||||
"static": false,
|
||||
"proto": false,
|
||||
"kind": "init",
|
||||
"method": true,
|
||||
"value": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":145,"end":166,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":25}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": {
|
||||
"type": "TypeParameterDeclaration",
|
||||
"start":146,"end":149,"loc":{"start":{"line":5,"column":5},"end":{"line":5,"column":8}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TypeParameter",
|
||||
"start":147,"end":148,"loc":{"start":{"line":5,"column":6},"end":{"line":5,"column":7}},
|
||||
"name": "T",
|
||||
"variance": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":150,"end":158,"loc":{"start":{"line":5,"column":9},"end":{"line":5,"column":17}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":157,"end":158,"loc":{"start":{"line":5,"column":16},"end":{"line":5,"column":17}},
|
||||
"typeParameters": null,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":157,"end":158,"loc":{"start":{"line":5,"column":16},"end":{"line":5,"column":17},"identifierName":"T"},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":162,"end":166,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":25}}
|
||||
}
|
||||
},
|
||||
"optional": false
|
||||
}
|
||||
],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/this-annotation/default/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/this-annotation/default/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
function foo<T> (this : number = 2) {}
|
||||
73
packages/babel-parser/test/fixtures/flow/this-annotation/default/output.json
vendored
Normal file
73
packages/babel-parser/test/fixtures/flow/this-annotation/default/output.json
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
|
||||
"errors": [
|
||||
"SyntaxError: The `this` parameter may not have a default value. (1:17)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"typeParameters": {
|
||||
"type": "TypeParameterDeclaration",
|
||||
"start":12,"end":15,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":15}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TypeParameter",
|
||||
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}},
|
||||
"name": "T",
|
||||
"variance": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
"type": "AssignmentPattern",
|
||||
"start":17,"end":34,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":34}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":17,"end":30,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":30},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":22,"end":30,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":30}},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":24,"end":30,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":30}}
|
||||
}
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"type": "NumericLiteral",
|
||||
"start":33,"end":34,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":34}},
|
||||
"extra": {
|
||||
"rawValue": 2,
|
||||
"raw": "2"
|
||||
},
|
||||
"value": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":36,"end":38,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":38}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
7
packages/babel-parser/test/fixtures/flow/this-annotation/function-declaration/input.js
vendored
Normal file
7
packages/babel-parser/test/fixtures/flow/this-annotation/function-declaration/input.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
function foo (this : number, a : string, b) {}
|
||||
|
||||
function bar (this : number) {}
|
||||
|
||||
function baz (this : number, ...a) {}
|
||||
|
||||
function qux<T> (this : T) {}
|
||||
186
packages/babel-parser/test/fixtures/flow/this-annotation/function-declaration/output.json
vendored
Normal file
186
packages/babel-parser/test/fixtures/flow/this-annotation/function-declaration/output.json
vendored
Normal file
@ -0,0 +1,186 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":149,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":29}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":149,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":29}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":14,"end":27,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":27},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":19,"end":27,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":27}},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":21,"end":27,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":27}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":29,"end":39,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":39},"identifierName":"a"},
|
||||
"name": "a",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":31,"end":39,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":39}},
|
||||
"typeAnnotation": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":33,"end":39,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":39}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":41,"end":42,"loc":{"start":{"line":1,"column":41},"end":{"line":1,"column":42},"identifierName":"b"},
|
||||
"name": "b"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":44,"end":46,"loc":{"start":{"line":1,"column":44},"end":{"line":1,"column":46}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start":48,"end":79,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":31}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":57,"end":60,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":12},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":62,"end":75,"loc":{"start":{"line":3,"column":14},"end":{"line":3,"column":27},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":67,"end":75,"loc":{"start":{"line":3,"column":19},"end":{"line":3,"column":27}},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":69,"end":75,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":27}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":77,"end":79,"loc":{"start":{"line":3,"column":29},"end":{"line":3,"column":31}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start":81,"end":118,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":37}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":90,"end":93,"loc":{"start":{"line":5,"column":9},"end":{"line":5,"column":12},"identifierName":"baz"},
|
||||
"name": "baz"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":95,"end":108,"loc":{"start":{"line":5,"column":14},"end":{"line":5,"column":27},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":100,"end":108,"loc":{"start":{"line":5,"column":19},"end":{"line":5,"column":27}},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":102,"end":108,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":27}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":110,"end":114,"loc":{"start":{"line":5,"column":29},"end":{"line":5,"column":33}},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start":113,"end":114,"loc":{"start":{"line":5,"column":32},"end":{"line":5,"column":33},"identifierName":"a"},
|
||||
"name": "a"
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":116,"end":118,"loc":{"start":{"line":5,"column":35},"end":{"line":5,"column":37}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start":120,"end":149,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":29}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":129,"end":132,"loc":{"start":{"line":7,"column":9},"end":{"line":7,"column":12},"identifierName":"qux"},
|
||||
"name": "qux"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"typeParameters": {
|
||||
"type": "TypeParameterDeclaration",
|
||||
"start":132,"end":135,"loc":{"start":{"line":7,"column":12},"end":{"line":7,"column":15}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TypeParameter",
|
||||
"start":133,"end":134,"loc":{"start":{"line":7,"column":13},"end":{"line":7,"column":14}},
|
||||
"name": "T",
|
||||
"variance": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":137,"end":145,"loc":{"start":{"line":7,"column":17},"end":{"line":7,"column":25},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":142,"end":145,"loc":{"start":{"line":7,"column":22},"end":{"line":7,"column":25}},
|
||||
"typeAnnotation": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":144,"end":145,"loc":{"start":{"line":7,"column":24},"end":{"line":7,"column":25}},
|
||||
"typeParameters": null,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":144,"end":145,"loc":{"start":{"line":7,"column":24},"end":{"line":7,"column":25},"identifierName":"T"},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":147,"end":149,"loc":{"start":{"line":7,"column":27},"end":{"line":7,"column":29}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
7
packages/babel-parser/test/fixtures/flow/this-annotation/function-type/input.js
vendored
Normal file
7
packages/babel-parser/test/fixtures/flow/this-annotation/function-type/input.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
type T = (this : number, a : string, b : number) => void
|
||||
|
||||
type U = (this : number, ...c : any) => void
|
||||
|
||||
type V = (this : number) => void
|
||||
|
||||
type Q = <T>(this : T) => void
|
||||
196
packages/babel-parser/test/fixtures/flow/this-annotation/function-type/output.json
vendored
Normal file
196
packages/babel-parser/test/fixtures/flow/this-annotation/function-type/output.json
vendored
Normal file
@ -0,0 +1,196 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":168,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":30}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":168,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":30}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TypeAlias",
|
||||
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":56}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"T"},
|
||||
"name": "T"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":9,"end":56,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":56}},
|
||||
"params": [
|
||||
{
|
||||
"type": "FunctionTypeParam",
|
||||
"start":25,"end":35,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":35}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":25,"end":26,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":26},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":29,"end":35,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":35}}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FunctionTypeParam",
|
||||
"start":37,"end":47,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":47}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":37,"end":38,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":38},"identifierName":"b"},
|
||||
"name": "b"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":41,"end":47,"loc":{"start":{"line":1,"column":41},"end":{"line":1,"column":47}}
|
||||
}
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":10,"end":23,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":23}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":17,"end":23,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":23}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":52,"end":56,"loc":{"start":{"line":1,"column":52},"end":{"line":1,"column":56}}
|
||||
},
|
||||
"typeParameters": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TypeAlias",
|
||||
"start":58,"end":102,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":44}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":63,"end":64,"loc":{"start":{"line":3,"column":5},"end":{"line":3,"column":6},"identifierName":"U"},
|
||||
"name": "U"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":67,"end":102,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":44}},
|
||||
"params": [],
|
||||
"rest": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":86,"end":93,"loc":{"start":{"line":3,"column":28},"end":{"line":3,"column":35}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":86,"end":87,"loc":{"start":{"line":3,"column":28},"end":{"line":3,"column":29},"identifierName":"c"},
|
||||
"name": "c"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "AnyTypeAnnotation",
|
||||
"start":90,"end":93,"loc":{"start":{"line":3,"column":32},"end":{"line":3,"column":35}}
|
||||
}
|
||||
},
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":68,"end":81,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":23}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":75,"end":81,"loc":{"start":{"line":3,"column":17},"end":{"line":3,"column":23}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":98,"end":102,"loc":{"start":{"line":3,"column":40},"end":{"line":3,"column":44}}
|
||||
},
|
||||
"typeParameters": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TypeAlias",
|
||||
"start":104,"end":136,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":32}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":109,"end":110,"loc":{"start":{"line":5,"column":5},"end":{"line":5,"column":6},"identifierName":"V"},
|
||||
"name": "V"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":113,"end":136,"loc":{"start":{"line":5,"column":9},"end":{"line":5,"column":32}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":114,"end":127,"loc":{"start":{"line":5,"column":10},"end":{"line":5,"column":23}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":121,"end":127,"loc":{"start":{"line":5,"column":17},"end":{"line":5,"column":23}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":132,"end":136,"loc":{"start":{"line":5,"column":28},"end":{"line":5,"column":32}}
|
||||
},
|
||||
"typeParameters": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TypeAlias",
|
||||
"start":138,"end":168,"loc":{"start":{"line":7,"column":0},"end":{"line":7,"column":30}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":143,"end":144,"loc":{"start":{"line":7,"column":5},"end":{"line":7,"column":6},"identifierName":"Q"},
|
||||
"name": "Q"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":147,"end":168,"loc":{"start":{"line":7,"column":9},"end":{"line":7,"column":30}},
|
||||
"typeParameters": {
|
||||
"type": "TypeParameterDeclaration",
|
||||
"start":147,"end":150,"loc":{"start":{"line":7,"column":9},"end":{"line":7,"column":12}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TypeParameter",
|
||||
"start":148,"end":149,"loc":{"start":{"line":7,"column":10},"end":{"line":7,"column":11}},
|
||||
"name": "T",
|
||||
"variance": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":151,"end":159,"loc":{"start":{"line":7,"column":13},"end":{"line":7,"column":21}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":158,"end":159,"loc":{"start":{"line":7,"column":20},"end":{"line":7,"column":21}},
|
||||
"typeParameters": null,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":158,"end":159,"loc":{"start":{"line":7,"column":20},"end":{"line":7,"column":21},"identifierName":"T"},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":164,"end":168,"loc":{"start":{"line":7,"column":26},"end":{"line":7,"column":30}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
6
packages/babel-parser/test/fixtures/flow/this-annotation/method/input.js
vendored
Normal file
6
packages/babel-parser/test/fixtures/flow/this-annotation/method/input.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
class A {
|
||||
m(this : number, a : number, b : string) {}
|
||||
n(this : number, ...c) {}
|
||||
o(this : number) {}
|
||||
p<T>(this : T) {}
|
||||
}
|
||||
226
packages/babel-parser/test/fixtures/flow/this-annotation/method/output.json
vendored
Normal file
226
packages/babel-parser/test/fixtures/flow/this-annotation/method/output.json
vendored
Normal file
@ -0,0 +1,226 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":135,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":135,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":135,"loc":{"start":{"line":1,"column":0},"end":{"line":6,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"A"},
|
||||
"name": "A"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":8,"end":135,"loc":{"start":{"line":1,"column":8},"end":{"line":6,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start":14,"end":57,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":47}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":14,"end":15,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":5},"identifierName":"m"},
|
||||
"name": "m"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":16,"end":29,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":19},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":21,"end":29,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":19}},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":23,"end":29,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":19}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":31,"end":41,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":31},"identifierName":"a"},
|
||||
"name": "a",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":33,"end":41,"loc":{"start":{"line":2,"column":23},"end":{"line":2,"column":31}},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":35,"end":41,"loc":{"start":{"line":2,"column":25},"end":{"line":2,"column":31}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":43,"end":53,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":43},"identifierName":"b"},
|
||||
"name": "b",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":45,"end":53,"loc":{"start":{"line":2,"column":35},"end":{"line":2,"column":43}},
|
||||
"typeAnnotation": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":47,"end":53,"loc":{"start":{"line":2,"column":37},"end":{"line":2,"column":43}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":55,"end":57,"loc":{"start":{"line":2,"column":45},"end":{"line":2,"column":47}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start":62,"end":87,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":29}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":62,"end":63,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":5},"identifierName":"n"},
|
||||
"name": "n"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":64,"end":77,"loc":{"start":{"line":3,"column":6},"end":{"line":3,"column":19},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":69,"end":77,"loc":{"start":{"line":3,"column":11},"end":{"line":3,"column":19}},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":71,"end":77,"loc":{"start":{"line":3,"column":13},"end":{"line":3,"column":19}}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "RestElement",
|
||||
"start":79,"end":83,"loc":{"start":{"line":3,"column":21},"end":{"line":3,"column":25}},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start":82,"end":83,"loc":{"start":{"line":3,"column":24},"end":{"line":3,"column":25},"identifierName":"c"},
|
||||
"name": "c"
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":85,"end":87,"loc":{"start":{"line":3,"column":27},"end":{"line":3,"column":29}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start":92,"end":111,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":23}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":92,"end":93,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":5},"identifierName":"o"},
|
||||
"name": "o"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":94,"end":107,"loc":{"start":{"line":4,"column":6},"end":{"line":4,"column":19},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":99,"end":107,"loc":{"start":{"line":4,"column":11},"end":{"line":4,"column":19}},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":101,"end":107,"loc":{"start":{"line":4,"column":13},"end":{"line":4,"column":19}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":109,"end":111,"loc":{"start":{"line":4,"column":21},"end":{"line":4,"column":23}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start":116,"end":133,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":21}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":116,"end":117,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":5},"identifierName":"p"},
|
||||
"name": "p"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"typeParameters": {
|
||||
"type": "TypeParameterDeclaration",
|
||||
"start":117,"end":120,"loc":{"start":{"line":5,"column":5},"end":{"line":5,"column":8}},
|
||||
"params": [
|
||||
{
|
||||
"type": "TypeParameter",
|
||||
"start":118,"end":119,"loc":{"start":{"line":5,"column":6},"end":{"line":5,"column":7}},
|
||||
"name": "T",
|
||||
"variance": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":121,"end":129,"loc":{"start":{"line":5,"column":9},"end":{"line":5,"column":17},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":126,"end":129,"loc":{"start":{"line":5,"column":14},"end":{"line":5,"column":17}},
|
||||
"typeAnnotation": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":128,"end":129,"loc":{"start":{"line":5,"column":16},"end":{"line":5,"column":17}},
|
||||
"typeParameters": null,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":128,"end":129,"loc":{"start":{"line":5,"column":16},"end":{"line":5,"column":17},"identifierName":"T"},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":131,"end":133,"loc":{"start":{"line":5,"column":19},"end":{"line":5,"column":21}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
5
packages/babel-parser/test/fixtures/flow/this-annotation/object-constructor/input.js
vendored
Normal file
5
packages/babel-parser/test/fixtures/flow/this-annotation/object-constructor/input.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
// @flow
|
||||
|
||||
({
|
||||
constructor(this: number){}
|
||||
})
|
||||
77
packages/babel-parser/test/fixtures/flow/this-annotation/object-constructor/output.json
vendored
Normal file
77
packages/babel-parser/test/fixtures/flow/this-annotation/object-constructor/output.json
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":2}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":2}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":10,"end":47,"loc":{"start":{"line":3,"column":0},"end":{"line":5,"column":2}},
|
||||
"leadingComments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": " @flow",
|
||||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}
|
||||
}
|
||||
],
|
||||
"expression": {
|
||||
"type": "ObjectExpression",
|
||||
"start":11,"end":46,"loc":{"start":{"line":3,"column":1},"end":{"line":5,"column":1}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 10
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectMethod",
|
||||
"start":17,"end":44,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":31}},
|
||||
"method": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":17,"end":28,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":15},"identifierName":"constructor"},
|
||||
"name": "constructor"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":29,"end":41,"loc":{"start":{"line":4,"column":16},"end":{"line":4,"column":28},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":33,"end":41,"loc":{"start":{"line":4,"column":20},"end":{"line":4,"column":28}},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":35,"end":41,"loc":{"start":{"line":4,"column":22},"end":{"line":4,"column":28}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":42,"end":44,"loc":{"start":{"line":4,"column":29},"end":{"line":4,"column":31}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": " @flow",
|
||||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
type T = {
|
||||
foo(a : number, this : number) : void
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":54,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: The `this` parameter must be the first function parameter. (2:20)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":54,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TypeAlias",
|
||||
"start":0,"end":54,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"T"},
|
||||
"name": "T"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start":9,"end":54,"loc":{"start":{"line":1,"column":9},"end":{"line":3,"column":1}},
|
||||
"callProperties": [],
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start":15,"end":52,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":41}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":15,"end":18,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"static": false,
|
||||
"proto": false,
|
||||
"kind": "init",
|
||||
"method": true,
|
||||
"value": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":15,"end":52,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":41}},
|
||||
"params": [
|
||||
{
|
||||
"type": "FunctionTypeParam",
|
||||
"start":19,"end":29,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":18}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":19,"end":20,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":9},"identifierName":"a"},
|
||||
"name": "a"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":23,"end":29,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":18}}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FunctionTypeParam",
|
||||
"start":31,"end":44,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":33}},
|
||||
"name": {
|
||||
"type": "Identifier",
|
||||
"start":31,"end":35,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":24},"identifierName":"this"},
|
||||
"name": "this"
|
||||
},
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":38,"end":44,"loc":{"start":{"line":2,"column":27},"end":{"line":2,"column":33}}
|
||||
}
|
||||
}
|
||||
],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":48,"end":52,"loc":{"start":{"line":2,"column":37},"end":{"line":2,"column":41}}
|
||||
}
|
||||
},
|
||||
"optional": false
|
||||
}
|
||||
],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false,
|
||||
"inexact": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/flow/this-annotation/object-method-type/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/this-annotation/object-method-type/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
type T = {
|
||||
foo(this : number) : void
|
||||
}
|
||||
69
packages/babel-parser/test/fixtures/flow/this-annotation/object-method-type/output.json
vendored
Normal file
69
packages/babel-parser/test/fixtures/flow/this-annotation/object-method-type/output.json
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
{
|
||||
"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": "TypeAlias",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"T"},
|
||||
"name": "T"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start":9,"end":42,"loc":{"start":{"line":1,"column":9},"end":{"line":3,"column":1}},
|
||||
"callProperties": [],
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start":15,"end":40,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":29}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":15,"end":18,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":7},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"static": false,
|
||||
"proto": false,
|
||||
"kind": "init",
|
||||
"method": true,
|
||||
"value": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":15,"end":40,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":29}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":19,"end":32,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":21}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":26,"end":32,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":21}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":36,"end":40,"loc":{"start":{"line":2,"column":25},"end":{"line":2,"column":29}}
|
||||
}
|
||||
},
|
||||
"optional": false
|
||||
}
|
||||
],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false,
|
||||
"inexact": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
5
packages/babel-parser/test/fixtures/flow/this-annotation/object-type-constructor/input.js
vendored
Normal file
5
packages/babel-parser/test/fixtures/flow/this-annotation/object-type-constructor/input.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
// @flow
|
||||
|
||||
type T = {
|
||||
constructor(this : number) : void
|
||||
}
|
||||
83
packages/babel-parser/test/fixtures/flow/this-annotation/object-type-constructor/output.json
vendored
Normal file
83
packages/babel-parser/test/fixtures/flow/this-annotation/object-type-constructor/output.json
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":60,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":60,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TypeAlias",
|
||||
"start":10,"end":60,"loc":{"start":{"line":3,"column":0},"end":{"line":5,"column":1}},
|
||||
"leadingComments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": " @flow",
|
||||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}
|
||||
}
|
||||
],
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":15,"end":16,"loc":{"start":{"line":3,"column":5},"end":{"line":3,"column":6},"identifierName":"T"},
|
||||
"name": "T"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start":19,"end":60,"loc":{"start":{"line":3,"column":9},"end":{"line":5,"column":1}},
|
||||
"callProperties": [],
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start":25,"end":58,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":37}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":25,"end":36,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":15},"identifierName":"constructor"},
|
||||
"name": "constructor"
|
||||
},
|
||||
"static": false,
|
||||
"proto": false,
|
||||
"kind": "init",
|
||||
"method": true,
|
||||
"value": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":25,"end":58,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":37}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":37,"end":50,"loc":{"start":{"line":4,"column":16},"end":{"line":4,"column":29}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":44,"end":50,"loc":{"start":{"line":4,"column":23},"end":{"line":4,"column":29}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":54,"end":58,"loc":{"start":{"line":4,"column":33},"end":{"line":4,"column":37}}
|
||||
}
|
||||
},
|
||||
"optional": false
|
||||
}
|
||||
],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false,
|
||||
"inexact": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": " @flow",
|
||||
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}
|
||||
}
|
||||
]
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/this-annotation/this-arrow-function/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/this-annotation/this-arrow-function/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
let x = (this : number) => 0
|
||||
62
packages/babel-parser/test/fixtures/flow/this-annotation/this-arrow-function/output.json
vendored
Normal file
62
packages/babel-parser/test/fixtures/flow/this-annotation/this-arrow-function/output.json
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
|
||||
"errors": [
|
||||
"SyntaxError: Binding invalid left-hand side in function parameter list (1:9)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":4,"end":28,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":28}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"x"},
|
||||
"name": "x"
|
||||
},
|
||||
"init": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start":8,"end":28,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":28}},
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "ThisExpression",
|
||||
"start":9,"end":22,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":22}},
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":14,"end":22,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":22}},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":16,"end":22,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":22}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "NumericLiteral",
|
||||
"start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}},
|
||||
"extra": {
|
||||
"rawValue": 0,
|
||||
"raw": "0"
|
||||
},
|
||||
"value": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "let"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/flow/this-annotation/this-constructor-declare/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/this-annotation/this-constructor-declare/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
declare class A {
|
||||
constructor(this : number) : A;
|
||||
}
|
||||
80
packages/babel-parser/test/fixtures/flow/this-annotation/this-constructor-declare/output.json
vendored
Normal file
80
packages/babel-parser/test/fixtures/flow/this-annotation/this-constructor-declare/output.json
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions. (2:16)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareClass",
|
||||
"start":0,"end":55,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"A"},
|
||||
"name": "A"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start":16,"end":55,"loc":{"start":{"line":1,"column":16},"end":{"line":3,"column":1}},
|
||||
"callProperties": [],
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start":22,"end":52,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":34}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":22,"end":33,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":15},"identifierName":"constructor"},
|
||||
"name": "constructor"
|
||||
},
|
||||
"static": false,
|
||||
"proto": false,
|
||||
"kind": "init",
|
||||
"method": true,
|
||||
"value": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":22,"end":52,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":34}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":34,"end":47,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":29}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start":41,"end":47,"loc":{"start":{"line":2,"column":23},"end":{"line":2,"column":29}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start":51,"end":52,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34}},
|
||||
"typeParameters": null,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":51,"end":52,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34},"identifierName":"A"},
|
||||
"name": "A"
|
||||
}
|
||||
}
|
||||
},
|
||||
"optional": false
|
||||
}
|
||||
],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/flow/this-annotation/this-constructor/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/this-annotation/this-constructor/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
class A {
|
||||
constructor(this: string) {}
|
||||
}
|
||||
68
packages/babel-parser/test/fixtures/flow/this-annotation/this-constructor/output.json
vendored
Normal file
68
packages/babel-parser/test/fixtures/flow/this-annotation/this-constructor/output.json
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions. (2:2)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"A"},
|
||||
"name": "A"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":8,"end":42,"loc":{"start":{"line":1,"column":8},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start":12,"end":40,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":30}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":12,"end":23,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":13},"identifierName":"constructor"},
|
||||
"name": "constructor"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "constructor",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":24,"end":36,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":26},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":28,"end":36,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":26}},
|
||||
"typeAnnotation": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":30,"end":36,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":26}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":38,"end":40,"loc":{"start":{"line":2,"column":28},"end":{"line":2,"column":30}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/flow/this-annotation/this-getter-type/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/this-annotation/this-getter-type/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
type T = {
|
||||
get foo(this: string) : void
|
||||
}
|
||||
72
packages/babel-parser/test/fixtures/flow/this-annotation/this-getter-type/output.json
vendored
Normal file
72
packages/babel-parser/test/fixtures/flow/this-annotation/this-getter-type/output.json
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: A getter cannot have a `this` parameter. (2:10)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "TypeAlias",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"T"},
|
||||
"name": "T"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"right": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start":9,"end":43,"loc":{"start":{"line":1,"column":9},"end":{"line":3,"column":1}},
|
||||
"callProperties": [],
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectTypeProperty",
|
||||
"start":13,"end":41,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":30}},
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":17,"end":20,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"static": false,
|
||||
"proto": false,
|
||||
"kind": "get",
|
||||
"method": true,
|
||||
"value": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":13,"end":41,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":30}},
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"typeParameters": null,
|
||||
"this": {
|
||||
"type": "FunctionTypeParam",
|
||||
"start":21,"end":33,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":22}},
|
||||
"name": null,
|
||||
"optional": false,
|
||||
"typeAnnotation": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":27,"end":33,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":22}}
|
||||
}
|
||||
},
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":37,"end":41,"loc":{"start":{"line":2,"column":26},"end":{"line":2,"column":30}}
|
||||
}
|
||||
},
|
||||
"optional": false
|
||||
}
|
||||
],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": false,
|
||||
"inexact": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/flow/this-annotation/this-getter/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/this-annotation/this-getter/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
get foo(this: string) {}
|
||||
}
|
||||
69
packages/babel-parser/test/fixtures/flow/this-annotation/this-getter/output.json
vendored
Normal file
69
packages/babel-parser/test/fixtures/flow/this-annotation/this-getter/output.json
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: getter must not have any formal parameters (2:2)",
|
||||
"SyntaxError: A getter cannot have a `this` parameter. (2:10)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":6,"end":9,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":9},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":10,"end":40,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start":14,"end":38,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":26}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":18,"end":21,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "get",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":22,"end":34,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":22},"identifierName":"this"},
|
||||
"name": "this",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":26,"end":34,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":22}},
|
||||
"typeAnnotation": {
|
||||
"type": "StringTypeAnnotation",
|
||||
"start":28,"end":34,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":22}}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":36,"end":38,"loc":{"start":{"line":2,"column":24},"end":{"line":2,"column":26}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/this-annotation/this-no-annot/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/this-annotation/this-no-annot/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
function foo (this) {}
|
||||
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