Fix some incorrect typeof parsing in flow (#10657)
This commit is contained in:
parent
10213655bc
commit
a502d88043
@ -22,12 +22,15 @@ import {
|
||||
SCOPE_OTHER,
|
||||
} from "../util/scopeflags";
|
||||
|
||||
const reservedTypes = [
|
||||
const reservedTypes = new Set([
|
||||
"_",
|
||||
"any",
|
||||
"bool",
|
||||
"boolean",
|
||||
"empty",
|
||||
"extends",
|
||||
"false",
|
||||
"interface",
|
||||
"mixed",
|
||||
"null",
|
||||
"number",
|
||||
@ -36,10 +39,7 @@ const reservedTypes = [
|
||||
"true",
|
||||
"typeof",
|
||||
"void",
|
||||
"interface",
|
||||
"extends",
|
||||
"_",
|
||||
];
|
||||
]);
|
||||
|
||||
function isEsModuleType(bodyElement: N.Node): boolean {
|
||||
return (
|
||||
@ -483,7 +483,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node: N.FlowDeclare,
|
||||
isClass?: boolean = false,
|
||||
): void {
|
||||
node.id = this.flowParseRestrictedIdentifier(/*liberal*/ !isClass);
|
||||
node.id = this.flowParseRestrictedIdentifier(
|
||||
/* liberal */ !isClass,
|
||||
/* declaration */ true,
|
||||
);
|
||||
|
||||
this.scope.declareName(
|
||||
node.id.name,
|
||||
@ -557,21 +560,32 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
}
|
||||
|
||||
checkReservedType(word: string, startLoc: number) {
|
||||
if (reservedTypes.indexOf(word) > -1) {
|
||||
checkReservedType(word: string, startLoc: number, declaration?: boolean) {
|
||||
if (!reservedTypes.has(word)) return;
|
||||
|
||||
if (declaration) {
|
||||
this.raise(startLoc, `Cannot overwrite reserved type ${word}`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.raise(startLoc, `Unexpected reserved type ${word}`);
|
||||
}
|
||||
|
||||
flowParseRestrictedIdentifier(liberal?: boolean): N.Identifier {
|
||||
this.checkReservedType(this.state.value, this.state.start);
|
||||
flowParseRestrictedIdentifier(
|
||||
liberal?: boolean,
|
||||
declaration?: boolean,
|
||||
): N.Identifier {
|
||||
this.checkReservedType(this.state.value, this.state.start, declaration);
|
||||
return this.parseIdentifier(liberal);
|
||||
}
|
||||
|
||||
// Type aliases
|
||||
|
||||
flowParseTypeAlias(node: N.FlowTypeAlias): N.FlowTypeAlias {
|
||||
node.id = this.flowParseRestrictedIdentifier();
|
||||
node.id = this.flowParseRestrictedIdentifier(
|
||||
/* liberal */ false,
|
||||
/* declaration */ true,
|
||||
);
|
||||
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
|
||||
|
||||
if (this.isRelational("<")) {
|
||||
@ -591,7 +605,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
declare: boolean,
|
||||
): N.FlowOpaqueType {
|
||||
this.expectContextual("type");
|
||||
node.id = this.flowParseRestrictedIdentifier(/*liberal*/ true);
|
||||
node.id = this.flowParseRestrictedIdentifier(
|
||||
/* liberal */ true,
|
||||
/* declaration */ true,
|
||||
);
|
||||
this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
|
||||
|
||||
if (this.isRelational("<")) {
|
||||
@ -1134,12 +1151,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
): N.FlowQualifiedTypeIdentifier {
|
||||
startPos = startPos || this.state.start;
|
||||
startLoc = startLoc || this.state.startLoc;
|
||||
let node = id || this.parseIdentifier();
|
||||
let node = id || this.flowParseRestrictedIdentifier(true);
|
||||
|
||||
while (this.eat(tt.dot)) {
|
||||
const node2 = this.startNodeAt(startPos, startLoc);
|
||||
node2.qualification = node;
|
||||
node2.id = this.parseIdentifier();
|
||||
node2.id = this.flowParseRestrictedIdentifier(true);
|
||||
node = this.finishNode(node2, "QualifiedTypeIdentifier");
|
||||
}
|
||||
|
||||
@ -2353,7 +2370,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
contextDescription: string,
|
||||
): void {
|
||||
specifier.local = hasTypeImportKind(node)
|
||||
? this.flowParseRestrictedIdentifier(true)
|
||||
? this.flowParseRestrictedIdentifier(
|
||||
/* liberal */ true,
|
||||
/* declaration */ true,
|
||||
)
|
||||
: this.parseIdentifier();
|
||||
|
||||
this.checkLVal(
|
||||
@ -2459,7 +2479,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
if (nodeIsTypeImport || specifierIsTypeImport) {
|
||||
this.checkReservedType(specifier.local.name, specifier.local.start);
|
||||
this.checkReservedType(
|
||||
specifier.local.name,
|
||||
specifier.local.start,
|
||||
/* declaration */ true,
|
||||
);
|
||||
}
|
||||
|
||||
if (isBinding && !nodeIsTypeImport && !specifierIsTypeImport) {
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
interface I extends X, bool {}
|
||||
@ -0,0 +1,197 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved type bool (2:23)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "InterfaceDeclaration",
|
||||
"start": 9,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "I"
|
||||
},
|
||||
"name": "I"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [
|
||||
{
|
||||
"type": "InterfaceExtends",
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"identifierName": "X"
|
||||
},
|
||||
"name": "X"
|
||||
},
|
||||
"typeParameters": null
|
||||
},
|
||||
{
|
||||
"type": "InterfaceExtends",
|
||||
"start": 32,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 32,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
},
|
||||
"identifierName": "bool"
|
||||
},
|
||||
"name": "bool"
|
||||
},
|
||||
"typeParameters": null
|
||||
}
|
||||
],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 37,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": 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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
interface I extends X, bool.m {}
|
||||
@ -0,0 +1,229 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved type bool (2:23)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "InterfaceDeclaration",
|
||||
"start": 9,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "I"
|
||||
},
|
||||
"name": "I"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [
|
||||
{
|
||||
"type": "InterfaceExtends",
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 29,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"identifierName": "X"
|
||||
},
|
||||
"name": "X"
|
||||
},
|
||||
"typeParameters": null
|
||||
},
|
||||
{
|
||||
"type": "InterfaceExtends",
|
||||
"start": 32,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "QualifiedTypeIdentifier",
|
||||
"start": 32,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"qualification": {
|
||||
"type": "Identifier",
|
||||
"start": 32,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
},
|
||||
"identifierName": "bool"
|
||||
},
|
||||
"name": "bool"
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 37,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
},
|
||||
"identifierName": "m"
|
||||
},
|
||||
"name": "m"
|
||||
}
|
||||
},
|
||||
"typeParameters": null
|
||||
}
|
||||
],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 39,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": 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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/interface-types/extends-reserved-invalid-1/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/interface-types/extends-reserved-invalid-1/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
interface I extends bool {}
|
||||
164
packages/babel-parser/test/fixtures/flow/interface-types/extends-reserved-invalid-1/output.json
vendored
Normal file
164
packages/babel-parser/test/fixtures/flow/interface-types/extends-reserved-invalid-1/output.json
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved type bool (2:20)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "InterfaceDeclaration",
|
||||
"start": 9,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "I"
|
||||
},
|
||||
"name": "I"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [
|
||||
{
|
||||
"type": "InterfaceExtends",
|
||||
"start": 29,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 29,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 24
|
||||
},
|
||||
"identifierName": "bool"
|
||||
},
|
||||
"name": "bool"
|
||||
},
|
||||
"typeParameters": null
|
||||
}
|
||||
],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 34,
|
||||
"end": 36,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 25
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": 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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/interface-types/extends-reserved-invalid-2/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/interface-types/extends-reserved-invalid-2/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
interface I extends bool.m {}
|
||||
196
packages/babel-parser/test/fixtures/flow/interface-types/extends-reserved-invalid-2/output.json
vendored
Normal file
196
packages/babel-parser/test/fixtures/flow/interface-types/extends-reserved-invalid-2/output.json
vendored
Normal file
@ -0,0 +1,196 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved type bool (2:20)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "InterfaceDeclaration",
|
||||
"start": 9,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "I"
|
||||
},
|
||||
"name": "I"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [
|
||||
{
|
||||
"type": "InterfaceExtends",
|
||||
"start": 29,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 26
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "QualifiedTypeIdentifier",
|
||||
"start": 29,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 26
|
||||
}
|
||||
},
|
||||
"qualification": {
|
||||
"type": "Identifier",
|
||||
"start": 29,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 24
|
||||
},
|
||||
"identifierName": "bool"
|
||||
},
|
||||
"name": "bool"
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 34,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 25
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 26
|
||||
},
|
||||
"identifierName": "m"
|
||||
},
|
||||
"name": "m"
|
||||
}
|
||||
},
|
||||
"typeParameters": null
|
||||
}
|
||||
],
|
||||
"implements": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 36,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"internalSlots": [],
|
||||
"exact": 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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
class Foo implements Bar, string {}
|
||||
@ -0,0 +1,155 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved type string (1:26)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 6,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"identifierName": "Foo"
|
||||
},
|
||||
"name": "Foo"
|
||||
},
|
||||
"superClass": null,
|
||||
"implements": [
|
||||
{
|
||||
"type": "ClassImplements",
|
||||
"start": 21,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 21,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 24
|
||||
},
|
||||
"identifierName": "Bar"
|
||||
},
|
||||
"name": "Bar"
|
||||
},
|
||||
"typeParameters": null
|
||||
},
|
||||
{
|
||||
"type": "ClassImplements",
|
||||
"start": 26,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 26,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 32
|
||||
},
|
||||
"identifierName": "string"
|
||||
},
|
||||
"name": "string"
|
||||
},
|
||||
"typeParameters": null
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 33,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 33
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@ -13,7 +13,7 @@
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Cannot overwrite reserved type string (1:21)"
|
||||
"SyntaxError: Unexpected reserved type string (1:21)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Cannot overwrite reserved type number (1:9)"
|
||||
"SyntaxError: Unexpected reserved type number (1:9)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Cannot overwrite reserved type string (1:11)"
|
||||
"SyntaxError: Unexpected reserved type string (1:11)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-1/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-1/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
const x: typeof interface = "hi";
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": [
|
||||
"jsx",
|
||||
"flow"
|
||||
],
|
||||
"throws": "Unexpected token, expected \"{\" (2:26)"
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-2/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-2/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
const x: typeof type.interface = "hi";
|
||||
239
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-2/output.json
vendored
Normal file
239
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-2/output.json
vendored
Normal file
@ -0,0 +1,239 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 47,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved type interface (2:21)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 47,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 9,
|
||||
"end": 47,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 38
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 15,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 37
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 16,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TypeofTypeAnnotation",
|
||||
"start": 18,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"argument": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start": 25,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"typeParameters": null,
|
||||
"id": {
|
||||
"type": "QualifiedTypeIdentifier",
|
||||
"start": 25,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"qualification": {
|
||||
"type": "Identifier",
|
||||
"start": 25,
|
||||
"end": 29,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 20
|
||||
},
|
||||
"identifierName": "type"
|
||||
},
|
||||
"name": "type"
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 30,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
},
|
||||
"identifierName": "interface"
|
||||
},
|
||||
"name": "interface"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"init": {
|
||||
"type": "StringLiteral",
|
||||
"start": 42,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 33
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 37
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "hi",
|
||||
"raw": "\"hi\""
|
||||
},
|
||||
"value": "hi"
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "const",
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-3/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-3/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
const x: typeof stuff.number = "hi";
|
||||
239
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-3/output.json
vendored
Normal file
239
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-3/output.json
vendored
Normal file
@ -0,0 +1,239 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 36
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved type number (2:22)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 36
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 9,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 36
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 15,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 16,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TypeofTypeAnnotation",
|
||||
"start": 18,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"argument": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start": 25,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"typeParameters": null,
|
||||
"id": {
|
||||
"type": "QualifiedTypeIdentifier",
|
||||
"start": 25,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"qualification": {
|
||||
"type": "Identifier",
|
||||
"start": 25,
|
||||
"end": 30,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"identifierName": "stuff"
|
||||
},
|
||||
"name": "stuff"
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 31,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
},
|
||||
"identifierName": "number"
|
||||
},
|
||||
"name": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"init": {
|
||||
"type": "StringLiteral",
|
||||
"start": 40,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 31
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "hi",
|
||||
"raw": "\"hi\""
|
||||
},
|
||||
"value": "hi"
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "const",
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-4/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-4/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
const x: typeof static = "hi";
|
||||
207
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-4/output.json
vendored
Normal file
207
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-4/output.json
vendored
Normal file
@ -0,0 +1,207 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved word 'static' (2:16)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 9,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 15,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 16,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TypeofTypeAnnotation",
|
||||
"start": 18,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"argument": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start": 25,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"typeParameters": null,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 25,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
},
|
||||
"identifierName": "static"
|
||||
},
|
||||
"name": "static"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"init": {
|
||||
"type": "StringLiteral",
|
||||
"start": 34,
|
||||
"end": 38,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 25
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "hi",
|
||||
"raw": "\"hi\""
|
||||
},
|
||||
"value": "hi"
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "const",
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-5/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-5/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
const x: typeof typeof = "hi";
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": [
|
||||
"jsx",
|
||||
"flow"
|
||||
],
|
||||
"throws": "Unexpected token (2:23)"
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-6/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-6/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// @flow
|
||||
const x: typeof d.i\u{6e}terface = "hi";
|
||||
239
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-6/output.json
vendored
Normal file
239
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-invalid-6/output.json
vendored
Normal file
@ -0,0 +1,239 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 40
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Unexpected reserved type interface (2:18)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 40
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "VariableDeclaration",
|
||||
"start": 9,
|
||||
"end": 49,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 40
|
||||
}
|
||||
},
|
||||
"declarations": [
|
||||
{
|
||||
"type": "VariableDeclarator",
|
||||
"start": 15,
|
||||
"end": 48,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 39
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 16,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TypeofTypeAnnotation",
|
||||
"start": 18,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"argument": {
|
||||
"type": "GenericTypeAnnotation",
|
||||
"start": 25,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"typeParameters": null,
|
||||
"id": {
|
||||
"type": "QualifiedTypeIdentifier",
|
||||
"start": 25,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
}
|
||||
},
|
||||
"qualification": {
|
||||
"type": "Identifier",
|
||||
"start": 25,
|
||||
"end": 26,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "d"
|
||||
},
|
||||
"name": "d"
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 27,
|
||||
"end": 41,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 32
|
||||
},
|
||||
"identifierName": "interface"
|
||||
},
|
||||
"name": "interface"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"init": {
|
||||
"type": "StringLiteral",
|
||||
"start": 44,
|
||||
"end": 48,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 35
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 39
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "hi",
|
||||
"raw": "\"hi\""
|
||||
},
|
||||
"value": "hi"
|
||||
}
|
||||
}
|
||||
],
|
||||
"kind": "const",
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
15
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-valid/input.js
vendored
Normal file
15
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-valid/input.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// @flow
|
||||
const a: typeof default = "hi";
|
||||
const b: typeof stuff.default = "hi";
|
||||
|
||||
const c: typeof any = "hi";
|
||||
const d: typeof bool = "hi";
|
||||
const e: typeof boolean = "hi";
|
||||
const f: typeof empty = "hi";
|
||||
const g: typeof false = "hi";
|
||||
const h: typeof mixed = "hi";
|
||||
const i: typeof null = "hi";
|
||||
const j: typeof number = "hi";
|
||||
const k: typeof string = "hi";
|
||||
const l: typeof true = "hi";
|
||||
const m: typeof void = "hi";
|
||||
1620
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-valid/output.json
vendored
Normal file
1620
packages/babel-parser/test/fixtures/flow/type-annotations/typeof-reserved-valid/output.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +0,0 @@
|
||||
{
|
||||
"sourceType": "module",
|
||||
"plugins": ["jsx", "flow"]
|
||||
}
|
||||
@ -13,7 +13,7 @@
|
||||
}
|
||||
},
|
||||
"errors": [
|
||||
"SyntaxError: Cannot overwrite reserved type _ (2:13)",
|
||||
"SyntaxError: Unexpected reserved type _ (2:13)",
|
||||
"SyntaxError: `_` is only allowed as a type argument to call or new (2:19)"
|
||||
],
|
||||
"program": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user