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

Flow commit: eb815be907

Babel PR: https://github.com/babel/babel/pull/7978
master
Brian Ng 2018-05-25 17:23:17 -05:00 committed by GitHub
parent d20d9c160e
commit fda7bf59f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

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),

View File

@ -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 }
`;

View File

@ -0,0 +1 @@
run_spec(__dirname, ["flow"]);

View File

@ -0,0 +1,3 @@
declare class A { proto: T; }
declare class B { proto x: T; }
declare class C { proto +x: T; }