Add support for explicit type arguments in new and call expressions (#7934)

* Add all option to babel-plugin-syntax-flow

The Flow parser has some conditional logic based on whether types should
be parsed or not, which is based on either (a) the @flow pragma in the
docblock of the file of (b) the `all` configuration, provided via
command line or .flowconfig.

This commit adds the ability to provide the `all` configuration to
Babel as well, via the syntax-flow plugin. This should be set to `true`
if the project uses all=true.

* Parse @flow pragma

The Flow parser has some conditional logic based on whether types should
be parsed or not, which is based on either (a) the @flow pragma in the
docblock of the file of (b) the `all` configuration, provided via
command line or .flowconfig.

This commit parses the @flow (or @noflow) pragma from the first comment
in the source file. Directives are allowed to appear before the comment.

* WIP: add tests for explicit type arguments

This commit includes tests which have unexpected output, but will change
to the expected output as later commits add parsing support for various
features.

* Parse type arguments in new expressions

* Parse type arguments in call expressions

* Parse optional call expressions with explicit type args

* Add explicit type arguments to babel-types

Flow calls these typeArguments instead of typeParameters, which clearly
separates formal/actual parameters, and mirrors the existing arguments
key.

The existing definitions to support TypeScript also included Flow's
TypeParameterInstantiation node type, which I've moved to the the new
field.

* Add support for explicit type arguments to babel-generator

* Add test for explicit type args to transform-flow-strip-types plugin

* Oops. Forgot to regenerate the babel-types README.

* Fix Flow parser shouldParseTypes() function

I was looking at `options.all`, but the correct property ws
`options.flowAll`. Oops!

* Remove typeapp_call from whitelist of expected failures

Now that Babylon parses this syntax extension, we can remove the
typeapp_call tests from the list of expected differences.

Note that I am using the `flowAll` option, mirroring the behavior of the
Flow tests, which assume types without requiring the `@flow` pragma.

* Use Babylon plugin options instead of parser options

* Parse optional call expressions type arguments unambiguously
This commit is contained in:
Sam Goldman 2018-05-18 14:05:16 +01:00 committed by Brian Ng
parent 6226c52f43
commit a40f54f847
52 changed files with 3422 additions and 23 deletions

View File

@ -67,6 +67,7 @@ export function NewExpression(node: Object, parent: Object) {
return; return;
} }
this.print(node.typeArguments, node); // Flow
this.print(node.typeParameters, node); // TS this.print(node.typeParameters, node); // TS
if (node.optional) { if (node.optional) {
@ -125,6 +126,7 @@ export function OptionalMemberExpression(node: Object) {
export function OptionalCallExpression(node: Object) { export function OptionalCallExpression(node: Object) {
this.print(node.callee, node); this.print(node.callee, node);
this.print(node.typeArguments, node); // Flow
this.print(node.typeParameters, node); // TS this.print(node.typeParameters, node); // TS
if (node.optional) { if (node.optional) {
@ -138,6 +140,7 @@ export function OptionalCallExpression(node: Object) {
export function CallExpression(node: Object) { export function CallExpression(node: Object) {
this.print(node.callee, node); this.print(node.callee, node);
this.print(node.typeArguments, node); // Flow
this.print(node.typeParameters, node); // TS this.print(node.typeParameters, node); // TS
this.token("("); this.token("(");
this.printList(node.arguments, node); this.printList(node.arguments, node);

View File

@ -0,0 +1,18 @@
// @flow
f<T>();
f<T><U></U>;
new C<T>;
f<T>(e);
o[e]<T>();
f<T>(x)<U>(y);
async <T>() => {};
async <T>(): T => {}
new C<T>(e);
f<T>[e];
new C<T>();
o.m<T>();
f<T>.0;
o?.m<T>(e);
o.m?.<T>(e);
async<T>();
f?.<T>(e);

View File

@ -0,0 +1 @@
{ "plugins": ["jsx", "optionalChaining", "flow"] }

View File

@ -0,0 +1,21 @@
// @flow
f<T>();
f < T > <U></U>;
new C<T>();
f<T>(e);
o[e]<T>();
f<T>(x)<U>(y);
async <T>() => {};
async <T>(): T => {};
new C<T>(e);
f < T > [e];
new C<T>();
o.m<T>();
f < T > .0;
o?.m<T>(e);
o.m<T>?.(e);
async<T>();
f<T>?.(e);

View File

@ -1,11 +1,15 @@
import { declare } from "@babel/helper-plugin-utils"; import { declare } from "@babel/helper-plugin-utils";
export default declare(api => { export default declare((api, options) => {
api.assertVersion(7); api.assertVersion(7);
// When enabled and plugins includes flow, all files should be parsed as if
// the @flow pragma was provided.
const { all } = options;
return { return {
manipulateOptions(opts, parserOpts) { manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("flow"); parserOpts.plugins.push(["flow", { all }]);
}, },
}; };
}); });

View File

@ -108,6 +108,21 @@ export default declare(api => {
} while (t.isTypeCastExpression(node)); } while (t.isTypeCastExpression(node));
path.replaceWith(node); path.replaceWith(node);
}, },
CallExpression({ node }) {
if (skipStrip) return;
node.typeArguments = null;
},
OptionalCallExpression({ node }) {
if (skipStrip) return;
node.typeArguments = null;
},
NewExpression({ node }) {
if (skipStrip) return;
node.typeArguments = null;
},
}, },
}; };
}); });

View File

@ -0,0 +1,18 @@
// @flow
f<T>();
f<T><U></U>;
new C<T>;
f<T>(e);
o[e]<T>();
f<T>(x)<U>(y);
async <T>() => {};
async <T>(): T => {}
new C<T>(e);
f<T>[e];
new C<T>();
o.m<T>();
f<T>.0;
o?.m<T>(e);
o.m?.<T>(e);
async<T>();
f?.<T>(e);

View File

@ -0,0 +1,3 @@
{
"plugins": ["syntax-jsx", "syntax-optional-chaining", "transform-flow-strip-types"]
}

View File

@ -0,0 +1,20 @@
f();
f < T > <U></U>;
new C();
f(e);
o[e]();
f(x)(y);
async () => {};
async () => {};
new C(e);
f < T > [e];
new C();
o.m();
f < T > .0;
o?.m(e);
o.m?.(e);
async();
f?.(e);

View File

@ -231,7 +231,8 @@ Aliases: `Expression`
- `callee`: `Expression` (required) - `callee`: `Expression` (required)
- `arguments`: `Array<Expression | SpreadElement | JSXNamespacedName>` (required) - `arguments`: `Array<Expression | SpreadElement | JSXNamespacedName>` (required)
- `optional`: `true | false` (default: `null`) - `optional`: `true | false` (default: `null`)
- `typeParameters`: `TypeParameterInstantiation | TSTypeParameterInstantiation` (default: `null`) - `typeArguments`: `TypeParameterInstantiation` (default: `null`)
- `typeParameters`: `TSTypeParameterInstantiation` (default: `null`)
--- ---
@ -1359,7 +1360,8 @@ Aliases: `Expression`
- `callee`: `Expression` (required) - `callee`: `Expression` (required)
- `arguments`: `Array<Expression | SpreadElement | JSXNamespacedName>` (required) - `arguments`: `Array<Expression | SpreadElement | JSXNamespacedName>` (required)
- `optional`: `true | false` (default: `null`) - `optional`: `true | false` (default: `null`)
- `typeParameters`: `TypeParameterInstantiation | TSTypeParameterInstantiation` (default: `null`) - `typeArguments`: `TypeParameterInstantiation` (default: `null`)
- `typeParameters`: `TSTypeParameterInstantiation` (default: `null`)
--- ---
@ -1621,7 +1623,8 @@ Aliases: `Expression`
- `callee`: `Expression` (required) - `callee`: `Expression` (required)
- `arguments`: `Array<Expression | SpreadElement | JSXNamespacedName>` (required) - `arguments`: `Array<Expression | SpreadElement | JSXNamespacedName>` (required)
- `optional`: `boolean` (required) - `optional`: `boolean` (required)
- `typeParameters`: `TypeParameterInstantiation | TSTypeParameterInstantiation` (default: `null`) - `typeArguments`: `TypeParameterInstantiation` (default: `null`)
- `typeParameters`: `TSTypeParameterInstantiation` (default: `null`)
--- ---

View File

@ -137,11 +137,12 @@ defineType("CallExpression", {
validate: assertOneOf(true, false), validate: assertOneOf(true, false),
optional: true, optional: true,
}, },
typeArguments: {
validate: assertNodeType("TypeParameterInstantiation"),
optional: true,
},
typeParameters: { typeParameters: {
validate: assertNodeType( validate: assertNodeType("TSTypeParameterInstantiation"),
"TypeParameterInstantiation",
"TSTypeParameterInstantiation",
),
optional: true, optional: true,
}, },
}, },

View File

@ -105,11 +105,12 @@ defineType("OptionalCallExpression", {
optional: { optional: {
validate: assertValueType("boolean"), validate: assertValueType("boolean"),
}, },
typeArguments: {
validate: assertNodeType("TypeParameterInstantiation"),
optional: true,
},
typeParameters: { typeParameters: {
validate: assertNodeType( validate: assertNodeType("TSTypeParameterInstantiation"),
"TypeParameterInstantiation",
"TSTypeParameterInstantiation",
),
optional: true, optional: true,
}, },
}, },

View File

@ -502,7 +502,6 @@ export default class ExpressionParser extends LValParser {
possibleAsync, possibleAsync,
); );
node.optional = true; node.optional = true;
return this.finishNode(node, "OptionalCallExpression"); return this.finishNode(node, "OptionalCallExpression");
} else { } else {
node.object = base; node.object = base;

View File

@ -23,6 +23,11 @@ export default class UtilParser extends Tokenizer {
return this.match(tt.relational) && this.state.value === op; return this.match(tt.relational) && this.state.value === op;
} }
isLookaheadRelational(op: "<" | ">"): boolean {
const l = this.lookahead();
return l.type == tt.relational && l.value == op;
}
// TODO // TODO
expectRelational(op: "<" | ">"): void { expectRelational(op: "<" | ">"): void {

View File

@ -64,8 +64,41 @@ function partition<T>(
return [list1, list2]; return [list1, list2];
} }
const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/;
export default (superClass: Class<Parser>): Class<Parser> => export default (superClass: Class<Parser>): Class<Parser> =>
class extends superClass { class extends superClass {
// The value of the @flow/@noflow pragma. Initially undefined, transitions
// to "@flow" or "@noflow" if we see a pragma. Transitions to null if we are
// past the initial comment.
flowPragma: void | null | "flow" | "noflow";
constructor(options: ?Options, input: string) {
super(options, input);
this.flowPragma = undefined;
}
shouldParseTypes(): boolean {
return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
}
addComment(comment: Comment): void {
if (this.flowPragma === undefined) {
// Try to parse a flow pragma.
const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
if (!matches) {
this.flowPragma = null;
} else if (matches[1] === "flow") {
this.flowPragma = "flow";
} else if (matches[1] === "noflow") {
this.flowPragma = "noflow";
} else {
throw new Error("Unexpected flow pragma");
}
}
return super.addComment(comment);
}
flowParseTypeInitialiser(tok?: TokenType): N.FlowType { flowParseTypeInitialiser(tok?: TokenType): N.FlowType {
const oldInType = this.state.inType; const oldInType = this.state.inType;
this.state.inType = true; this.state.inType = true;
@ -1370,7 +1403,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
this.next(); this.next();
return this.flowParseInterface(node); return this.flowParseInterface(node);
} else { } else {
return super.parseStatement(declaration, topLevel); const stmt = super.parseStatement(declaration, topLevel);
// We will parse a flow pragma in any comment before the first statement.
if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
this.flowPragma = null;
}
return stmt;
} }
} }
@ -2375,6 +2413,85 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return super.parseSubscripts(base, startPos, startLoc, noCalls); return super.parseSubscripts(base, startPos, startLoc, noCalls);
} }
parseSubscript(
base: N.Expression,
startPos: number,
startLoc: Position,
noCalls: ?boolean,
subscriptState: N.ParseSubscriptState,
): N.Expression {
if (this.match(tt.questionDot) && this.isLookaheadRelational("<")) {
this.expectPlugin("optionalChaining");
subscriptState.optionalChainMember = true;
if (noCalls) {
subscriptState.stop = true;
return base;
}
this.next();
const node: N.OptionalCallExpression = this.startNodeAt(
startPos,
startLoc,
);
node.callee = base;
node.typeArguments = this.flowParseTypeParameterInstantiation();
this.expect(tt.parenL);
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
node.optional = true;
return this.finishNode(node, "OptionalCallExpression");
} else if (
!noCalls &&
this.shouldParseTypes() &&
this.isRelational("<")
) {
const node: N.CallExpression = this.startNodeAt(startPos, startLoc);
node.callee = base;
const state = this.state.clone();
try {
node.typeArguments = this.flowParseTypeParameterInstantiation();
this.expect(tt.parenL);
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
if (subscriptState.optionalChainMember) {
node.optional = false;
return this.finishNode(node, "OptionalCallExpression");
}
return this.finishNode(node, "CallExpression");
} catch (e) {
if (e instanceof SyntaxError) {
this.state = state;
} else {
throw e;
}
}
}
return super.parseSubscript(
base,
startPos,
startLoc,
noCalls,
subscriptState,
);
}
parseNewArguments(node: N.NewExpression): void {
let targs = null;
if (this.shouldParseTypes() && this.isRelational("<")) {
const state = this.state.clone();
try {
targs = this.flowParseTypeParameterInstantiation();
} catch (e) {
if (e instanceof SyntaxError) {
this.state = state;
} else {
throw e;
}
}
}
node.typeArguments = targs;
super.parseNewArguments(node);
}
parseAsyncArrowWithTypeParameters( parseAsyncArrowWithTypeParameters(
startPos: number, startPos: number,
startLoc: Position, startLoc: Position,

View File

@ -0,0 +1,2 @@
// @flow
async<T>();

View File

@ -0,0 +1,168 @@
{
"type": "File",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"program": {
"type": "Program",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"expression": {
"type": "CallExpression",
"start": 9,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"callee": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "async"
},
"name": "async"
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 14,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 8
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"arguments": []
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,3 @@
// @flow
async <T>() => {};
async <T>(): T => {}

View File

@ -0,0 +1,289 @@
{
"type": "File",
"start": 0,
"end": 48,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 20
}
},
"program": {
"type": "Program",
"start": 0,
"end": 48,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 20
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 18
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 9,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 17
}
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 15,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 9
}
},
"params": [
{
"type": "TypeParameter",
"start": 16,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
}
},
"name": "T",
"variance": null
}
]
},
"params": [],
"id": null,
"generator": false,
"async": true,
"body": {
"type": "BlockStatement",
"start": 24,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 17
}
},
"body": [],
"directives": []
}
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
},
{
"type": "ExpressionStatement",
"start": 28,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 20
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 28,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 20
}
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 34,
"end": 37,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 9
}
},
"params": [
{
"type": "TypeParameter",
"start": 35,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 8
}
},
"name": "T",
"variance": null
}
]
},
"params": [],
"predicate": null,
"returnType": {
"type": "TypeAnnotation",
"start": 39,
"end": 42,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 14
}
},
"typeAnnotation": {
"type": "GenericTypeAnnotation",
"start": 41,
"end": 42,
"loc": {
"start": {
"line": 3,
"column": 13
},
"end": {
"line": 3,
"column": 14
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 41,
"end": 42,
"loc": {
"start": {
"line": 3,
"column": 13
},
"end": {
"line": 3,
"column": 14
},
"identifierName": "T"
},
"name": "T"
}
}
},
"id": null,
"generator": false,
"async": true,
"body": {
"type": "BlockStatement",
"start": 46,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 18
},
"end": {
"line": 3,
"column": 20
}
},
"body": [],
"directives": []
}
}
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1 @@
f<T>(e);

View File

@ -0,0 +1,136 @@
{
"type": "File",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
},
"program": {
"type": "Program",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
},
"expression": {
"type": "BinaryExpression",
"start": 0,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 7
}
},
"left": {
"type": "BinaryExpression",
"start": 0,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"left": {
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "f"
},
"name": "f"
},
"operator": "<",
"right": {
"type": "Identifier",
"start": 2,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 3
},
"identifierName": "T"
},
"name": "T"
}
},
"operator": ">",
"right": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "e"
},
"name": "e",
"extra": {
"parenthesized": true,
"parenStart": 4
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
new C<T>(e);

View File

@ -0,0 +1,153 @@
{
"type": "File",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"program": {
"type": "Program",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"expression": {
"type": "BinaryExpression",
"start": 0,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 11
}
},
"left": {
"type": "BinaryExpression",
"start": 0,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 7
}
},
"left": {
"type": "NewExpression",
"start": 0,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 5
}
},
"callee": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "C"
},
"name": "C"
},
"typeArguments": null,
"arguments": []
},
"operator": "<",
"right": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "T"
},
"name": "T"
}
},
"operator": ">",
"right": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "e"
},
"name": "e",
"extra": {
"parenthesized": true,
"parenStart": 8
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,2 @@
// @flow
f<T>(x)<U>(y);

View File

@ -0,0 +1,270 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 14
}
},
"expression": {
"type": "CallExpression",
"start": 9,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 13
}
},
"callee": {
"type": "CallExpression",
"start": 9,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 7
}
},
"callee": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
},
"identifierName": "f"
},
"name": "f"
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 10,
"end": 13,
"loc": {
"start": {
"line": 2,
"column": 1
},
"end": {
"line": 2,
"column": 4
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"arguments": [
{
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
},
"identifierName": "x"
},
"name": "x"
}
]
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 16,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 10
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 9
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 9
},
"identifierName": "U"
},
"name": "U"
}
}
]
},
"arguments": [
{
"type": "Identifier",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "y"
},
"name": "y"
}
]
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
f?.<T>(e);

View File

@ -0,0 +1,3 @@
{
"plugins": ["jsx", "flow", "optionalChaining"]
}

View File

@ -0,0 +1,187 @@
{
"type": "File",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"program": {
"type": "Program",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"expression": {
"type": "OptionalCallExpression",
"start": 9,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 9
}
},
"callee": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
},
"identifierName": "f"
},
"name": "f"
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 12,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 6
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"arguments": [
{
"type": "Identifier",
"start": 16,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "e"
},
"name": "e"
}
],
"optional": true
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
f<T>();

View File

@ -0,0 +1,168 @@
{
"type": "File",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 7
}
},
"program": {
"type": "Program",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 7
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 7
}
},
"expression": {
"type": "CallExpression",
"start": 9,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"callee": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
},
"identifierName": "f"
},
"name": "f"
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 10,
"end": 13,
"loc": {
"start": {
"line": 2,
"column": 1
},
"end": {
"line": 2,
"column": 4
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"arguments": []
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
o[e]<T>();

View File

@ -0,0 +1,201 @@
{
"type": "File",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"program": {
"type": "Program",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"expression": {
"type": "CallExpression",
"start": 9,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 9
}
},
"callee": {
"type": "MemberExpression",
"start": 9,
"end": 13,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 4
}
},
"object": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
},
"identifierName": "o"
},
"name": "o"
},
"property": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
},
"identifierName": "e"
},
"name": "e"
},
"computed": true
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 13,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 7
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"arguments": []
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
o?.m<T>(e);

View File

@ -0,0 +1,3 @@
{
"plugins": ["jsx", "flow", "optionalChaining"]
}

View File

@ -0,0 +1,221 @@
{
"type": "File",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"program": {
"type": "Program",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"expression": {
"type": "OptionalCallExpression",
"start": 9,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"callee": {
"type": "OptionalMemberExpression",
"start": 9,
"end": 13,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 4
}
},
"object": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
},
"identifierName": "o"
},
"name": "o"
},
"property": {
"type": "Identifier",
"start": 12,
"end": 13,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "m"
},
"name": "m"
},
"computed": false,
"optional": true
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 13,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 7
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"arguments": [
{
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 9
},
"identifierName": "e"
},
"name": "e"
}
],
"optional": false
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
o.m?.<T>(e);

View File

@ -0,0 +1,3 @@
{
"plugins": ["jsx", "flow", "optionalChaining"]
}

View File

@ -0,0 +1,220 @@
{
"type": "File",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 12
}
},
"program": {
"type": "Program",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 12
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 12
}
},
"expression": {
"type": "OptionalCallExpression",
"start": 9,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"callee": {
"type": "MemberExpression",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"object": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
},
"identifierName": "o"
},
"name": "o"
},
"property": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
},
"identifierName": "m"
},
"name": "m"
},
"computed": false
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 14,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 8
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"arguments": [
{
"type": "Identifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "e"
},
"name": "e"
}
],
"optional": true
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
o.m<T>();

View File

@ -0,0 +1,201 @@
{
"type": "File",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 9
}
},
"program": {
"type": "Program",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 9
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 9
}
},
"expression": {
"type": "CallExpression",
"start": 9,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"callee": {
"type": "MemberExpression",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"object": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
},
"identifierName": "o"
},
"name": "o"
},
"property": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
},
"identifierName": "m"
},
"name": "m"
},
"computed": false
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 12,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 6
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"arguments": []
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
new C<T>;

View File

@ -0,0 +1,168 @@
{
"type": "File",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 9
}
},
"program": {
"type": "Program",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 9
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 9
}
},
"expression": {
"type": "NewExpression",
"start": 9,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"callee": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "C"
},
"name": "C"
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 14,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 8
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"arguments": []
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
new C<T>();

View File

@ -0,0 +1,168 @@
{
"type": "File",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"program": {
"type": "Program",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"expression": {
"type": "NewExpression",
"start": 9,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 10
}
},
"callee": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "C"
},
"name": "C"
},
"typeArguments": {
"type": "TypeParameterInstantiation",
"start": 14,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 8
}
},
"params": [
{
"type": "GenericTypeAnnotation",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "T"
},
"name": "T"
}
}
]
},
"arguments": []
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
f<T>[e];

View File

@ -0,0 +1,185 @@
{
"type": "File",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"program": {
"type": "Program",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 8
}
},
"expression": {
"type": "BinaryExpression",
"start": 9,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 7
}
},
"left": {
"type": "BinaryExpression",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"left": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
},
"identifierName": "f"
},
"name": "f"
},
"operator": "<",
"right": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
},
"identifierName": "T"
},
"name": "T"
}
},
"operator": ">",
"right": {
"type": "ArrayExpression",
"start": 13,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 7
}
},
"elements": [
{
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
},
"identifierName": "e"
},
"name": "e"
}
]
}
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
f<T>.0;

View File

@ -0,0 +1,171 @@
{
"type": "File",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 7
}
},
"program": {
"type": "Program",
"start": 0,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 7
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 7
}
},
"expression": {
"type": "BinaryExpression",
"start": 9,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 6
}
},
"left": {
"type": "BinaryExpression",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"left": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
},
"identifierName": "f"
},
"name": "f"
},
"operator": "<",
"right": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
},
"identifierName": "T"
},
"name": "T"
}
},
"operator": ">",
"right": {
"type": "NumericLiteral",
"start": 13,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 6
}
},
"extra": {
"rawValue": 0,
"raw": ".0"
},
"value": 0
}
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -0,0 +1,2 @@
// @flow
f<T><U></U>;

View File

@ -0,0 +1,231 @@
{
"type": "File",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 12
}
},
"program": {
"type": "Program",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 12
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 9,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 12
}
},
"expression": {
"type": "BinaryExpression",
"start": 9,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 11
}
},
"left": {
"type": "BinaryExpression",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 3
}
},
"left": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 1
},
"identifierName": "f"
},
"name": "f"
},
"operator": "<",
"right": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
},
"identifierName": "T"
},
"name": "T"
}
},
"operator": ">",
"right": {
"type": "JSXElement",
"start": 13,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 11
}
},
"openingElement": {
"type": "JSXOpeningElement",
"start": 13,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 7
}
},
"attributes": [],
"name": {
"type": "JSXIdentifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
}
},
"name": "U"
},
"selfClosing": false
},
"closingElement": {
"type": "JSXClosingElement",
"start": 16,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 11
}
},
"name": {
"type": "JSXIdentifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
}
},
"name": "U"
}
},
"children": []
}
},
"leadingComments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " @flow",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
}
}
]
}

View File

@ -37,11 +37,4 @@ numbers/underscored_float_whole.js
numbers/underscored_hex.js numbers/underscored_hex.js
numbers/underscored_number.js numbers/underscored_number.js
numbers/underscored_oct.js numbers/underscored_oct.js
typeapp_call/function_call.js
typeapp_call/function_call_optional.js
typeapp_call/method_call.js
typeapp_call/method_call_computed.js
typeapp_call/method_call_optional2.js
typeapp_call/new.js
typeapp_call/new_noparens.js
types/declare_class/proto.js types/declare_class/proto.js

View File

@ -111,7 +111,7 @@ const options = {
plugins: [ plugins: [
"asyncGenerators", "asyncGenerators",
"dynamicImport", "dynamicImport",
"flow", ["flow", { all: true }],
"flowComments", "flowComments",
"jsx", "jsx",
"objectRestSpread", "objectRestSpread",