Fix private property parsing in Flow (#8340)

* Fix private property parsing in Flow

* Flow tests updated

* Fix type error

* Appropriate name was given to test folder

* Fix

* Empty

* Correct type annotation

* Add required changes in generator package

* Add required changes in flow-strip-types
This commit is contained in:
kalenikalexander
2018-08-02 09:38:58 +03:00
committed by Nicolò Ribaudo
parent b8f9ebf638
commit 5c728ea609
18 changed files with 559 additions and 2 deletions

View File

@@ -1917,6 +1917,15 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return super.parseClassProperty(node);
}
parseClassPrivateProperty(
node: N.ClassPrivateProperty,
): N.ClassPrivateProperty {
if (this.match(tt.colon)) {
node.typeAnnotation = this.flowParseTypeAnnotation();
}
return super.parseClassPrivateProperty(node);
}
// determine whether or not we're currently in the position where a class method would appear
isClassMethod(): boolean {
return this.isRelational("<") || super.isClassMethod();

View File

@@ -717,6 +717,7 @@ export type ClassPrivateProperty = NodeBase & {
value: ?Expression, // TODO: Not in spec that this is nullable.
static: boolean,
computed: false,
typeAnnotation?: ?TypeAnnotation, // TODO: Not in spec
};
export type OptClassDeclaration = ClassBase &