Allow static? as identifier in ObjectTypeProperty
This commit is contained in:
parent
77445cb044
commit
65ca968f8b
@ -668,10 +668,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
while (!this.match(endDelim)) {
|
while (!this.match(endDelim)) {
|
||||||
let isStatic = false;
|
let isStatic = false;
|
||||||
const node = this.startNode();
|
const node = this.startNode();
|
||||||
|
const lookahead = this.lookahead();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
allowStatic &&
|
allowStatic &&
|
||||||
this.isContextual("static") &&
|
this.isContextual("static") &&
|
||||||
this.lookahead().type !== tt.colon
|
// static is a valid identifier name
|
||||||
|
(lookahead.type !== tt.colon && lookahead.type !== tt.question)
|
||||||
) {
|
) {
|
||||||
this.next();
|
this.next();
|
||||||
isStatic = true;
|
isStatic = true;
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
interface B { static?: number }
|
||||||
@ -0,0 +1,142 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 31,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 31,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "InterfaceDeclaration",
|
||||||
|
"start": 0,
|
||||||
|
"end": 31,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 10,
|
||||||
|
"end": 11,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 11
|
||||||
|
},
|
||||||
|
"identifierName": "B"
|
||||||
|
},
|
||||||
|
"name": "B"
|
||||||
|
},
|
||||||
|
"typeParameters": null,
|
||||||
|
"extends": [],
|
||||||
|
"implements": [],
|
||||||
|
"mixins": [],
|
||||||
|
"body": {
|
||||||
|
"type": "ObjectTypeAnnotation",
|
||||||
|
"start": 12,
|
||||||
|
"end": 31,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 12
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 31
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callProperties": [],
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"type": "ObjectTypeProperty",
|
||||||
|
"start": 14,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 14
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 14,
|
||||||
|
"end": 20,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 14
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 20
|
||||||
|
},
|
||||||
|
"identifierName": "static"
|
||||||
|
},
|
||||||
|
"name": "static"
|
||||||
|
},
|
||||||
|
"static": false,
|
||||||
|
"kind": "init",
|
||||||
|
"method": false,
|
||||||
|
"value": {
|
||||||
|
"type": "NumberTypeAnnotation",
|
||||||
|
"start": 23,
|
||||||
|
"end": 29,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 29
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"variance": null,
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"indexers": [],
|
||||||
|
"exact": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
33
packages/babylon/test/fixtures/flow/type-annotations/function-param-reserved/output.json
vendored
Normal file
33
packages/babylon/test/fixtures/flow/type-annotations/function-param-reserved/output.json
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 0,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 0,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "module",
|
||||||
|
"body": [],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -37,4 +37,3 @@ types/parameter_defaults/migrated_0031.js
|
|||||||
types/parameter_defaults/migrated_0032.js
|
types/parameter_defaults/migrated_0032.js
|
||||||
types/typecasts_invalid/migrated_0001.js
|
types/typecasts_invalid/migrated_0001.js
|
||||||
class_method_kinds/polymorphic_getter.js
|
class_method_kinds/polymorphic_getter.js
|
||||||
types/interfaces/prop_named_static.js
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user