Allows the interface to be used as an Identifier for flow plugin (#12254)
This commit is contained in:
parent
a967910b8b
commit
f5bd9f2013
@ -13,7 +13,7 @@ import type { Pos, Position } from "../util/location";
|
||||
import type State from "../tokenizer/state";
|
||||
import { types as tc } from "../tokenizer/context";
|
||||
import * as charCodes from "charcodes";
|
||||
import { isIteratorStart } from "../util/identifier";
|
||||
import { isIteratorStart, isKeyword } from "../util/identifier";
|
||||
import {
|
||||
type BindingTypes,
|
||||
BIND_NONE,
|
||||
@ -1735,14 +1735,17 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
this.match(tt.name) &&
|
||||
this.state.value === "interface"
|
||||
) {
|
||||
const lookahead = this.lookahead();
|
||||
if (lookahead.type === tt.name || isKeyword(lookahead.value)) {
|
||||
const node = this.startNode();
|
||||
this.next();
|
||||
return this.flowParseInterface(node);
|
||||
}
|
||||
} else if (this.shouldParseEnums() && this.isContextual("enum")) {
|
||||
const node = this.startNode();
|
||||
this.next();
|
||||
return this.flowParseEnumDeclaration(node);
|
||||
} else {
|
||||
}
|
||||
const stmt = super.parseStatement(context, topLevel);
|
||||
// We will parse a flow pragma in any comment before the first statement.
|
||||
if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
|
||||
@ -1750,7 +1753,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
}
|
||||
|
||||
// declares, interfaces and type aliases
|
||||
parseExpressionStatement(
|
||||
|
||||
@ -0,0 +1 @@
|
||||
interface = "foo";
|
||||
@ -0,0 +1,39 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}},
|
||||
"expression": {
|
||||
"type": "AssignmentExpression",
|
||||
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
|
||||
"operator": "=",
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
"right": {
|
||||
"type": "StringLiteral",
|
||||
"start":12,"end":17,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":17}},
|
||||
"extra": {
|
||||
"rawValue": "foo",
|
||||
"raw": "\"foo\""
|
||||
},
|
||||
"value": "foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/binary-expression/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/binary-expression/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
interface + 3;
|
||||
39
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/binary-expression/output.json
vendored
Normal file
39
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/binary-expression/output.json
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
|
||||
"expression": {
|
||||
"type": "BinaryExpression",
|
||||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
"operator": "+",
|
||||
"right": {
|
||||
"type": "NumericLiteral",
|
||||
"start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13}},
|
||||
"extra": {
|
||||
"rawValue": 3,
|
||||
"raw": "3"
|
||||
},
|
||||
"value": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/call-expression/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/call-expression/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
interface();
|
||||
30
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/call-expression/output.json
vendored
Normal file
30
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/call-expression/output.json
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
"arguments": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/class-declaration/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/class-declaration/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
class interface {}
|
||||
31
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/class-declaration/output.json
vendored
Normal file
31
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/class-declaration/output.json
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:6)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":6,"end":15,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":15},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":16,"end":18,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":18}},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
interface ? true : false;
|
||||
@ -0,0 +1,39 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
|
||||
"expression": {
|
||||
"type": "ConditionalExpression",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"test": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
"consequent": {
|
||||
"type": "BooleanLiteral",
|
||||
"start":12,"end":16,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":16}},
|
||||
"value": true
|
||||
},
|
||||
"alternate": {
|
||||
"type": "BooleanLiteral",
|
||||
"start":19,"end":24,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":24}},
|
||||
"value": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
function interface() {}
|
||||
@ -0,0 +1,34 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:9)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":18,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":18},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":21,"end":23,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":23}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/import-statement/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/import-statement/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
import interface from "foo";
|
||||
41
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/import-statement/output.json
vendored
Normal file
41
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/import-statement/output.json
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:7)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ImportDeclaration",
|
||||
"start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},
|
||||
"specifiers": [
|
||||
{
|
||||
"type": "ImportDefaultSpecifier",
|
||||
"start":7,"end":16,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":16}},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start":7,"end":16,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":16},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
}
|
||||
}
|
||||
],
|
||||
"importKind": "value",
|
||||
"source": {
|
||||
"type": "StringLiteral",
|
||||
"start":22,"end":27,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":27}},
|
||||
"extra": {
|
||||
"rawValue": "foo",
|
||||
"raw": "\"foo\""
|
||||
},
|
||||
"value": "foo"
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/member-expression/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/member-expression/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
foo.interface;
|
||||
interface.foo;
|
||||
54
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/member-expression/output.json
vendored
Normal file
54
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/member-expression/output.json
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":14}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (2:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":14}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
|
||||
"expression": {
|
||||
"type": "MemberExpression",
|
||||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":3},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":13,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":13},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":15,"end":29,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":14}},
|
||||
"expression": {
|
||||
"type": "MemberExpression",
|
||||
"start":15,"end":28,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":13}},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start":15,"end":24,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":9},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
"computed": false,
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start":25,"end":28,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":13},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/new-expression/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/new-expression/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
new interface();
|
||||
31
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/new-expression/output.json
vendored
Normal file
31
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/new-expression/output.json
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:4)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
|
||||
"expression": {
|
||||
"type": "NewExpression",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start":4,"end":13,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":13},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
"typeArguments": null,
|
||||
"arguments": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/property/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/property/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
({
|
||||
interface: "foo"
|
||||
});
|
||||
48
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/property/output.json
vendored
Normal file
48
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/property/output.json
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":3}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":3}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":3}},
|
||||
"expression": {
|
||||
"type": "ObjectExpression",
|
||||
"start":1,"end":23,"loc":{"start":{"line":1,"column":1},"end":{"line":3,"column":1}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start":5,"end":21,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":18}},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":14,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":11},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
"start":16,"end":21,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18}},
|
||||
"extra": {
|
||||
"rawValue": "foo",
|
||||
"raw": "\"foo\""
|
||||
},
|
||||
"value": "foo"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
(interface, "foo");
|
||||
@ -0,0 +1,44 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:1)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
|
||||
"expression": {
|
||||
"type": "SequenceExpression",
|
||||
"start":1,"end":17,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":17}},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 0
|
||||
},
|
||||
"expressions": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start":1,"end":10,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":10},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
{
|
||||
"type": "StringLiteral",
|
||||
"start":12,"end":17,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":17}},
|
||||
"extra": {
|
||||
"rawValue": "foo",
|
||||
"raw": "\"foo\""
|
||||
},
|
||||
"value": "foo"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/unary-expression/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/unary-expression/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
void interface;
|
||||
31
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/unary-expression/output.json
vendored
Normal file
31
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/unary-expression/output.json
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:5)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"expression": {
|
||||
"type": "UnaryExpression",
|
||||
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
|
||||
"operator": "void",
|
||||
"prefix": true,
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start":5,"end":14,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":14},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/variable/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/variable/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
const interface = "foo";
|
||||
41
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/variable/output.json
vendored
Normal file
41
packages/babel-parser/test/fixtures/flow/interfaces-as-identifier/variable/output.json
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'interface' (1:6)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start":6,"end":23,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":23}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":6,"end":15,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":15},"identifierName":"interface"},
|
||||
"name": "interface"
|
||||
},
|
||||
"init": {
|
||||
"type": "StringLiteral",
|
||||
"start":18,"end":23,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":23}},
|
||||
"extra": {
|
||||
"rawValue": "foo",
|
||||
"raw": "\"foo\""
|
||||
},
|
||||
"value": "foo"
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "const"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user