Add support for Flow's proto modifier syntax (#4551)

Flow commit: https://github.com/facebook/flow/commit/eb815be907eeae9f4851ff154087ebf079510d18

Babel PR: https://github.com/babel/babel/pull/7978
This commit is contained in:
Brian Ng authored and GitHub committed 2018-05-25 17:23:17 -05:00
1 parent d20d9c160e
commit fda7bf59f4
4 files changed
+25 -1

No files matched your search

+9 -1
View File
@@ -2675,8 +2675,16 @@ function printPathNoParens(path, options, print, args) {
case "ObjectTypeProperty": {
const variance = getFlowVariance(n);
let modifier = "";
if (n.proto) {
modifier = "proto ";
} else if (n.static) {
modifier = "static ";
}
return concat([
n.static ? "static " : "",
modifier,
isGetterOrSetter(n) ? n.kind + " " : "",
variance || "",
printPropertyKey(path, options, print),
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`proto_props.js 1`] = `
declare class A { proto: T; }
declare class B { proto x: T; }
declare class C { proto +x: T; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare class A { proto: T }
declare class B { proto x: T }
declare class C { proto +x: T }
`;
+1
View File
@@ -0,0 +1 @@
run_spec(__dirname, ["flow"]);
+3
View File
@@ -0,0 +1,3 @@
declare class A { proto: T; }
declare class B { proto x: T; }
declare class C { proto +x: T; }