diff --git a/packages/babel-generator/src/generators/flow.js b/packages/babel-generator/src/generators/flow.js index 9bf5fd2fd7..d46118debd 100644 --- a/packages/babel-generator/src/generators/flow.js +++ b/packages/babel-generator/src/generators/flow.js @@ -472,6 +472,10 @@ export function ObjectTypeIndexer(node: Object) { } export function ObjectTypeProperty(node: Object) { + if (node.proto) { + this.word("proto"); + this.space(); + } if (node.static) { this.word("static"); this.space(); diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index f09babfa7d..dde77d49eb 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -427,7 +427,10 @@ export default (superClass: Class): Class => // Interfaces - flowParseInterfaceish(node: N.FlowDeclare, isClass?: boolean): void { + flowParseInterfaceish( + node: N.FlowDeclare, + isClass?: boolean = false, + ): void { node.id = this.flowParseRestrictedIdentifier(/*liberal*/ !isClass); if (this.isRelational("<")) { @@ -460,7 +463,7 @@ export default (superClass: Class): Class => } while (this.eat(tt.comma)); } - node.body = this.flowParseObjectType(true, false, false); + node.body = this.flowParseObjectType(true, false, false, isClass); } flowParseInterfaceExtends(): N.FlowInterfaceExtends { @@ -653,7 +656,7 @@ export default (superClass: Class): Class => } while (this.eat(tt.comma)); } - node.body = this.flowParseObjectType(true, false, false); + node.body = this.flowParseObjectType(true, false, false, false); return this.finishNode(node, "InterfaceTypeAnnotation"); } @@ -755,6 +758,7 @@ export default (superClass: Class): Class => allowStatic: boolean, allowExact: boolean, allowSpread: boolean, + allowProto: boolean, ): N.FlowObjectTypeAnnotation { const oldInType = this.state.inType; this.state.inType = true; @@ -782,8 +786,19 @@ export default (superClass: Class): Class => while (!this.match(endDelim)) { let isStatic = false; + let protoStart: ?number = null; const node = this.startNode(); + if (allowProto && this.isContextual("proto")) { + const lookahead = this.lookahead(); + + if (lookahead.type !== tt.colon && lookahead.type !== tt.question) { + this.next(); + protoStart = this.state.start; + allowStatic = false; + } + } + if (allowStatic && this.isContextual("static")) { const lookahead = this.lookahead(); @@ -797,6 +812,9 @@ export default (superClass: Class): Class => const variance = this.flowParseVariance(); if (this.eat(tt.bracketL)) { + if (protoStart != null) { + this.unexpected(protoStart); + } if (this.eat(tt.bracketL)) { if (variance) { this.unexpected(variance.start); @@ -810,6 +828,9 @@ export default (superClass: Class): Class => ); } } else if (this.match(tt.parenL) || this.isRelational("<")) { + if (protoStart != null) { + this.unexpected(protoStart); + } if (variance) { this.unexpected(variance.start); } @@ -835,6 +856,7 @@ export default (superClass: Class): Class => this.flowParseObjectTypeProperty( node, isStatic, + protoStart, variance, kind, allowSpread, @@ -857,6 +879,7 @@ export default (superClass: Class): Class => flowParseObjectTypeProperty( node: N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty, isStatic: boolean, + protoStart: ?number, variance: ?N.FlowVariance, kind: string, allowSpread: boolean, @@ -868,6 +891,9 @@ export default (superClass: Class): Class => "Spread operator cannot appear in class or interface definitions", ); } + if (protoStart != null) { + this.unexpected(protoStart); + } if (variance) { this.unexpected( variance.start, @@ -881,6 +907,7 @@ export default (superClass: Class): Class => } else { node.key = this.flowParseObjectPropertyKey(); node.static = isStatic; + node.proto = protoStart != null; node.kind = kind; let optional = false; @@ -888,6 +915,9 @@ export default (superClass: Class): Class => // This is a method property node.method = true; + if (protoStart != null) { + this.unexpected(protoStart); + } if (variance) { this.unexpected(variance.start); } @@ -1116,10 +1146,10 @@ export default (superClass: Class): Class => ); case tt.braceL: - return this.flowParseObjectType(false, false, true); + return this.flowParseObjectType(false, false, true, false); case tt.braceBarL: - return this.flowParseObjectType(false, true, true); + return this.flowParseObjectType(false, true, true, false); case tt.bracketL: return this.flowParseTupleType(); diff --git a/packages/babel-parser/test/fixtures/flow/call-properties/3/output.json b/packages/babel-parser/test/fixtures/flow/call-properties/3/output.json index 730570fda7..b37fa63355 100644 --- a/packages/babel-parser/test/fixtures/flow/call-properties/3/output.json +++ b/packages/babel-parser/test/fixtures/flow/call-properties/3/output.json @@ -284,6 +284,7 @@ "name": "y" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/class-properties/getter-setter/output.json b/packages/babel-parser/test/fixtures/flow/class-properties/getter-setter/output.json index 4a75d993f4..78d487b01a 100644 --- a/packages/babel-parser/test/fixtures/flow/class-properties/getter-setter/output.json +++ b/packages/babel-parser/test/fixtures/flow/class-properties/getter-setter/output.json @@ -112,6 +112,7 @@ "name": "a" }, "static": false, + "proto": false, "kind": "get", "method": true, "value": { @@ -181,6 +182,7 @@ "name": "b" }, "static": false, + "proto": false, "kind": "set", "method": true, "value": { @@ -302,6 +304,7 @@ "value": "c" }, "static": false, + "proto": false, "kind": "get", "method": true, "value": { @@ -374,6 +377,7 @@ "value": "d" }, "static": false, + "proto": false, "kind": "set", "method": true, "value": { @@ -495,6 +499,7 @@ "value": 1 }, "static": false, + "proto": false, "kind": "get", "method": true, "value": { @@ -567,6 +572,7 @@ "value": 2 }, "static": false, + "proto": false, "kind": "set", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/class-properties/named-static/output.json b/packages/babel-parser/test/fixtures/flow/class-properties/named-static/output.json index fc9b86cfab..81db157812 100644 --- a/packages/babel-parser/test/fixtures/flow/class-properties/named-static/output.json +++ b/packages/babel-parser/test/fixtures/flow/class-properties/named-static/output.json @@ -112,6 +112,7 @@ "name": "static" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/comment/02-type-include/output.json b/packages/babel-parser/test/fixtures/flow/comment/02-type-include/output.json index 1d0d65df29..81661e9066 100644 --- a/packages/babel-parser/test/fixtures/flow/comment/02-type-include/output.json +++ b/packages/babel-parser/test/fixtures/flow/comment/02-type-include/output.json @@ -109,6 +109,7 @@ "name": "foo" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -161,6 +162,7 @@ "name": "bar" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -213,6 +215,7 @@ "name": "baz" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/output.json b/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/output.json index 027f0b871f..3a740e6c1c 100644 --- a/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/output.json +++ b/packages/babel-parser/test/fixtures/flow/comment/03-type-flow-include/output.json @@ -109,6 +109,7 @@ "name": "foo" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -161,6 +162,7 @@ "name": "bar" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -213,6 +215,7 @@ "name": "baz" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/declare-export/export-class/output.json b/packages/babel-parser/test/fixtures/flow/declare-export/export-class/output.json index 5d62e9f780..3f8a99853e 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-export/export-class/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-export/export-class/output.json @@ -175,6 +175,7 @@ "name": "meth" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/10/output.json b/packages/babel-parser/test/fixtures/flow/declare-module/10/output.json index 25e88a589d..563b25f29e 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-module/10/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-module/10/output.json @@ -105,6 +105,7 @@ "name": "foo" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/5/output.json b/packages/babel-parser/test/fixtures/flow/declare-module/5/output.json index 61696e0296..4135f43e1d 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-module/5/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-module/5/output.json @@ -158,6 +158,7 @@ "name": "foo" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/6/output.json b/packages/babel-parser/test/fixtures/flow/declare-module/6/output.json index 7816d81300..33f1898db5 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-module/6/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-module/6/output.json @@ -151,6 +151,7 @@ "name": "foo" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/declare-statements/10/output.json b/packages/babel-parser/test/fixtures/flow/declare-statements/10/output.json index bc426abd72..cf4fbe9e78 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-statements/10/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-statements/10/output.json @@ -112,6 +112,7 @@ "name": "foo" }, "static": true, + "proto": false, "kind": "init", "method": true, "value": { @@ -181,6 +182,7 @@ "name": "x" }, "static": true, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json b/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json index 64ec483e78..6af031abc6 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json @@ -112,6 +112,7 @@ "name": "foo" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -254,6 +255,7 @@ "name": "foo" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/declare-statements/17/output.json b/packages/babel-parser/test/fixtures/flow/declare-statements/17/output.json index e3aa79850a..26cebcf0a0 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-statements/17/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-statements/17/output.json @@ -112,6 +112,7 @@ "name": "a" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -164,6 +165,7 @@ "name": "b" }, "static": true, + "proto": false, "kind": "init", "method": false, "value": { @@ -216,6 +218,7 @@ "name": "c" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/declare-statements/7/output.json b/packages/babel-parser/test/fixtures/flow/declare-statements/7/output.json index e0077da6c9..6ad6e00493 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-statements/7/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-statements/7/output.json @@ -112,6 +112,7 @@ "name": "didAnimate" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/declare-statements/9/output.json b/packages/babel-parser/test/fixtures/flow/declare-statements/9/output.json index 12af2df0eb..0191d716d9 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-statements/9/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-statements/9/output.json @@ -228,6 +228,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/interface-types/basic/output.json b/packages/babel-parser/test/fixtures/flow/interface-types/basic/output.json index 30725acb6b..9e75058274 100644 --- a/packages/babel-parser/test/fixtures/flow/interface-types/basic/output.json +++ b/packages/babel-parser/test/fixtures/flow/interface-types/basic/output.json @@ -124,6 +124,7 @@ "name": "p" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/interface-types/extends-multiple/output.json b/packages/babel-parser/test/fixtures/flow/interface-types/extends-multiple/output.json index 89d37fdfbd..8ca1c30e33 100644 --- a/packages/babel-parser/test/fixtures/flow/interface-types/extends-multiple/output.json +++ b/packages/babel-parser/test/fixtures/flow/interface-types/extends-multiple/output.json @@ -191,6 +191,7 @@ "name": "p" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/interface-types/extends/output.json b/packages/babel-parser/test/fixtures/flow/interface-types/extends/output.json index d8aaec47be..2d6da1e733 100644 --- a/packages/babel-parser/test/fixtures/flow/interface-types/extends/output.json +++ b/packages/babel-parser/test/fixtures/flow/interface-types/extends/output.json @@ -158,6 +158,7 @@ "name": "p" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/10/output.json b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/10/output.json index ff19586af0..c582203ef1 100644 --- a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/10/output.json +++ b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/10/output.json @@ -162,6 +162,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -214,6 +215,7 @@ "name": "y" }, "static": true, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/4/output.json b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/4/output.json index 59070088dd..88174f7dee 100644 --- a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/4/output.json +++ b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/4/output.json @@ -112,6 +112,7 @@ "name": "foo" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/5/output.json b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/5/output.json index 05ed8a6cb0..4235a52169 100644 --- a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/5/output.json +++ b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/5/output.json @@ -112,6 +112,7 @@ "name": "length" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/identifier-named-static-optional/output.json b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/identifier-named-static-optional/output.json index 0973810770..f51323cb52 100644 --- a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/identifier-named-static-optional/output.json +++ b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/identifier-named-static-optional/output.json @@ -112,6 +112,7 @@ "name": "static" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/iterator/01/output.json b/packages/babel-parser/test/fixtures/flow/iterator/01/output.json index c3fbdf8d99..60270d94f8 100644 --- a/packages/babel-parser/test/fixtures/flow/iterator/01/output.json +++ b/packages/babel-parser/test/fixtures/flow/iterator/01/output.json @@ -112,6 +112,7 @@ "name": "@@iterator" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/iterator/02/output.json b/packages/babel-parser/test/fixtures/flow/iterator/02/output.json index e366b98aba..b2c7bca4a7 100644 --- a/packages/babel-parser/test/fixtures/flow/iterator/02/output.json +++ b/packages/babel-parser/test/fixtures/flow/iterator/02/output.json @@ -112,6 +112,7 @@ "name": "@@asyncIterator" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/iterator/12/output.json b/packages/babel-parser/test/fixtures/flow/iterator/12/output.json index 76bdb9060e..523dd9f5cb 100644 --- a/packages/babel-parser/test/fixtures/flow/iterator/12/output.json +++ b/packages/babel-parser/test/fixtures/flow/iterator/12/output.json @@ -126,6 +126,7 @@ "name": "@@iterator" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/iterator/13/output.json b/packages/babel-parser/test/fixtures/flow/iterator/13/output.json index fcd55f3d9e..7162d07e7f 100644 --- a/packages/babel-parser/test/fixtures/flow/iterator/13/output.json +++ b/packages/babel-parser/test/fixtures/flow/iterator/13/output.json @@ -126,6 +126,7 @@ "name": "@@asyncIterator" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/iterator/14/output.json b/packages/babel-parser/test/fixtures/flow/iterator/14/output.json index 104005a21e..399c914de9 100644 --- a/packages/babel-parser/test/fixtures/flow/iterator/14/output.json +++ b/packages/babel-parser/test/fixtures/flow/iterator/14/output.json @@ -112,6 +112,7 @@ "name": "@@iterator" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/iterator/15/output.json b/packages/babel-parser/test/fixtures/flow/iterator/15/output.json index 06a289f59e..8c08078cbf 100644 --- a/packages/babel-parser/test/fixtures/flow/iterator/15/output.json +++ b/packages/babel-parser/test/fixtures/flow/iterator/15/output.json @@ -112,6 +112,7 @@ "name": "@@asyncIterator" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/object-types/complex-param-types/output.json b/packages/babel-parser/test/fixtures/flow/object-types/complex-param-types/output.json index b077c4d261..4bd3e696e5 100644 --- a/packages/babel-parser/test/fixtures/flow/object-types/complex-param-types/output.json +++ b/packages/babel-parser/test/fixtures/flow/object-types/complex-param-types/output.json @@ -109,6 +109,7 @@ "name": "m" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-alias/4/output.json b/packages/babel-parser/test/fixtures/flow/type-alias/4/output.json index de7427eac8..c7bc622454 100644 --- a/packages/babel-parser/test/fixtures/flow/type-alias/4/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-alias/4/output.json @@ -124,6 +124,7 @@ "name": "type" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -202,6 +203,7 @@ "name": "type" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -529,6 +531,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -594,6 +597,7 @@ "name": "type" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -672,6 +676,7 @@ "name": "type" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -793,6 +798,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -858,6 +864,7 @@ "name": "type" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -936,6 +943,7 @@ "name": "type" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/108/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/108/output.json index 7c4eca5bdf..59d32d37d0 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/108/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/108/output.json @@ -136,6 +136,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -188,6 +189,7 @@ "name": "y" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -453,6 +455,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -505,6 +508,7 @@ "name": "y" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -871,6 +875,7 @@ "name": "a" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -921,6 +926,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -973,6 +979,7 @@ "name": "y" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -1033,6 +1040,7 @@ "name": "b" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -1401,6 +1409,7 @@ "name": "a" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -1451,6 +1460,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -1503,6 +1513,7 @@ "name": "y" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -1563,6 +1574,7 @@ "name": "b" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/110/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/110/output.json index 225455da09..4929bc3d47 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/110/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/110/output.json @@ -109,6 +109,7 @@ "name": "p" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/111/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/111/output.json index b3576a690b..afb693e336 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/111/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/111/output.json @@ -109,6 +109,7 @@ "name": "p" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/136/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/136/output.json index 029d546ff7..f2a1f069cf 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/136/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/136/output.json @@ -109,6 +109,7 @@ "name": "p" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/32/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/32/output.json index f3458824c5..6e85ab61db 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/32/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/32/output.json @@ -136,6 +136,7 @@ "name": "numVal" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/33/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/33/output.json index 5c7fd6c380..5b4664821d 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/33/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/33/output.json @@ -136,6 +136,7 @@ "name": "numVal" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/34/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/34/output.json index 48a58e6371..e0cef862f3 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/34/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/34/output.json @@ -136,6 +136,7 @@ "name": "numVal" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/35/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/35/output.json index c2fb3a7508..42d9e07ef5 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/35/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/35/output.json @@ -150,6 +150,7 @@ "name": "numVal" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/36/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/36/output.json index f0e400efb2..fee4f6be45 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/36/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/36/output.json @@ -136,6 +136,7 @@ "name": "numVal" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -188,6 +189,7 @@ "name": "strVal" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/37/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/37/output.json index 38e102d2ef..24897a890d 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/37/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/37/output.json @@ -136,6 +136,7 @@ "name": "subObj" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -186,6 +187,7 @@ "name": "strVal" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/38/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/38/output.json index 4ea9c51ba1..537525fd50 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/38/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/38/output.json @@ -136,6 +136,7 @@ "name": "subObj" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -200,6 +201,7 @@ "name": "strVal" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/39/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/39/output.json index ed1680dc2f..fe3cbacc4b 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/39/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/39/output.json @@ -136,6 +136,7 @@ "name": "param1" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -188,6 +189,7 @@ "name": "param2" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/40/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/40/output.json index 228f4c051b..ed33244fe9 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/40/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/40/output.json @@ -136,6 +136,7 @@ "name": "param1" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -188,6 +189,7 @@ "name": "param2" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/42/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/42/output.json index 00fb848af9..446275326e 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/42/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/42/output.json @@ -136,6 +136,7 @@ "name": "add" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/43/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/43/output.json index 854d4de36b..027091719c 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/43/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/43/output.json @@ -136,6 +136,7 @@ "name": "id" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/60/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/60/output.json index 72a7785ae3..1f013f7840 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/60/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/60/output.json @@ -191,6 +191,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/61/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/61/output.json index f474fad90b..c26e02abf8 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/61/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/61/output.json @@ -191,6 +191,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/63/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/63/output.json index bf72fe7dd3..7311b8c241 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/63/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/63/output.json @@ -196,6 +196,7 @@ "name": "x" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/98/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/98/output.json index 804b26e46c..669cab2fd5 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/98/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/98/output.json @@ -136,6 +136,7 @@ "name": "param1" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -188,6 +189,7 @@ "name": "param2" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -240,6 +242,7 @@ "name": "param3" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json index 061922e807..61c974a718 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json @@ -109,6 +109,7 @@ "name": "a" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -233,6 +234,7 @@ "name": "a" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -390,6 +392,7 @@ "name": "a" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -513,6 +516,7 @@ "name": "a" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -978,6 +982,7 @@ "name": "foo" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -1104,6 +1109,7 @@ "name": "foo" }, "static": true, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-exports/interface/output.json b/packages/babel-parser/test/fixtures/flow/type-exports/interface/output.json index 432b4d7398..01516efbba 100644 --- a/packages/babel-parser/test/fixtures/flow/type-exports/interface/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-exports/interface/output.json @@ -129,6 +129,7 @@ "name": "p" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -304,6 +305,7 @@ "name": "p" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/declare-class-method-reserved-word/output.json b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/declare-class-method-reserved-word/output.json index 236b8560c6..64b7c306de 100644 --- a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/declare-class-method-reserved-word/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/declare-class-method-reserved-word/output.json @@ -112,6 +112,7 @@ "name": "foobar" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -214,6 +215,7 @@ "name": "delete" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -316,6 +318,7 @@ "name": "yield" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -418,6 +421,7 @@ "name": "do" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -520,6 +524,7 @@ "name": "foobar" }, "static": true, + "proto": false, "kind": "init", "method": true, "value": { @@ -622,6 +627,7 @@ "name": "delete" }, "static": true, + "proto": false, "kind": "init", "method": true, "value": { @@ -724,6 +730,7 @@ "name": "yield" }, "static": true, + "proto": false, "kind": "init", "method": true, "value": { @@ -826,6 +833,7 @@ "name": "do" }, "static": true, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/declare-interface-method-reserved-word/output.json b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/declare-interface-method-reserved-word/output.json index bbf0eafcd9..cffd72d465 100644 --- a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/declare-interface-method-reserved-word/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/declare-interface-method-reserved-word/output.json @@ -112,6 +112,7 @@ "name": "foobar" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -214,6 +215,7 @@ "name": "delete" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -316,6 +318,7 @@ "name": "yield" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -418,6 +421,7 @@ "name": "do" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/interface-reserved-word/output.json b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/interface-reserved-word/output.json index 07e53e6351..773dc48b8c 100644 --- a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/interface-reserved-word/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/interface-reserved-word/output.json @@ -112,6 +112,7 @@ "name": "foobar" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -214,6 +215,7 @@ "name": "delete" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -316,6 +318,7 @@ "name": "yield" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -418,6 +421,7 @@ "name": "do" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/type-object-reserved-word/output.json b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/type-object-reserved-word/output.json index fdee6a7291..0b9e5fd724 100644 --- a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/type-object-reserved-word/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/type-object-reserved-word/output.json @@ -109,6 +109,7 @@ "name": "foobar" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -211,6 +212,7 @@ "name": "delete" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -313,6 +315,7 @@ "name": "yield" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { @@ -415,6 +418,7 @@ "name": "do" }, "static": false, + "proto": false, "kind": "init", "method": true, "value": { diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/2/output.json b/packages/babel-parser/test/fixtures/flow/typecasts/2/output.json index 55e97ca130..45638f476d 100644 --- a/packages/babel-parser/test/fixtures/flow/typecasts/2/output.json +++ b/packages/babel-parser/test/fixtures/flow/typecasts/2/output.json @@ -246,6 +246,7 @@ "name": "xxx" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { @@ -298,6 +299,7 @@ "name": "yyy" }, "static": false, + "proto": false, "kind": "init", "method": false, "value": { diff --git a/packages/babel-types/README.md b/packages/babel-types/README.md index 8cb0e774f5..9919328406 100644 --- a/packages/babel-types/README.md +++ b/packages/babel-types/README.md @@ -1634,6 +1634,7 @@ Aliases: `Flow`, `UserWhitespacable` - `variance`: `Variance` (default: `null`) - `kind`: `"init" | "get" | "set"` (default: `null`) - `optional`: `boolean` (default: `null`) + - `proto`: `boolean` (default: `null`) - `static`: `boolean` (default: `null`) --- diff --git a/packages/babel-types/src/definitions/flow.js b/packages/babel-types/src/definitions/flow.js index 622fff3997..fa4ad6e52d 100644 --- a/packages/babel-types/src/definitions/flow.js +++ b/packages/babel-types/src/definitions/flow.js @@ -321,6 +321,7 @@ defineType("ObjectTypeProperty", { value: validateType("FlowType"), kind: validate(assertOneOf("init", "get", "set")), static: validate(assertValueType("boolean")), + proto: validate(assertValueType("boolean")), optional: validate(assertValueType("boolean")), variance: validateOptionalType("Variance"), }, diff --git a/packages/babylon/test/fixtures/flow/proto-props/declare-class/input.js b/packages/babylon/test/fixtures/flow/proto-props/declare-class/input.js new file mode 100644 index 0000000000..4a80666d14 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/proto-props/declare-class/input.js @@ -0,0 +1,11 @@ +declare class A { + proto: T; +} + +declare class B { + proto x: T; +} + +declare class C { + proto +x: T; +} diff --git a/packages/babylon/test/fixtures/flow/proto-props/declare-class/output.json b/packages/babylon/test/fixtures/flow/proto-props/declare-class/output.json new file mode 100644 index 0000000000..a3eea5b768 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/proto-props/declare-class/output.json @@ -0,0 +1,433 @@ +{ + "type": "File", + "start": 0, + "end": 102, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 102, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "sourceType": "module", + "body": [ + { + "type": "DeclareClass", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 16, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 20, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "key": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "proto" + }, + "name": "proto" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "GenericTypeAnnotation", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "T" + }, + "name": "T" + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false + } + }, + { + "type": "DeclareClass", + "start": 33, + "end": 66, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 47, + "end": 48, + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 15 + }, + "identifierName": "B" + }, + "name": "B" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 49, + "end": 66, + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 53, + "end": 63, + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "key": { + "type": "Identifier", + "start": 59, + "end": 60, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + }, + "identifierName": "x" + }, + "name": "x" + }, + "static": false, + "proto": true, + "kind": "init", + "method": false, + "value": { + "type": "GenericTypeAnnotation", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + }, + "identifierName": "T" + }, + "name": "T" + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false + } + }, + { + "type": "DeclareClass", + "start": 68, + "end": 102, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 82, + "end": 83, + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 15 + }, + "identifierName": "C" + }, + "name": "C" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 84, + "end": 102, + "loc": { + "start": { + "line": 9, + "column": 16 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 88, + "end": 99, + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 13 + } + }, + "key": { + "type": "Identifier", + "start": 95, + "end": 96, + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "static": false, + "proto": true, + "kind": "init", + "method": false, + "value": { + "type": "GenericTypeAnnotation", + "start": 98, + "end": 99, + "loc": { + "start": { + "line": 10, + "column": 12 + }, + "end": { + "line": 10, + "column": 13 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 98, + "end": 99, + "loc": { + "start": { + "line": 10, + "column": 12 + }, + "end": { + "line": 10, + "column": 13 + }, + "identifierName": "T" + }, + "name": "T" + } + }, + "variance": { + "type": "Variance", + "start": 94, + "end": 95, + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "kind": "plus" + }, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/proto-props/interface/input.js b/packages/babylon/test/fixtures/flow/proto-props/interface/input.js new file mode 100644 index 0000000000..5e8b3b0615 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/proto-props/interface/input.js @@ -0,0 +1,3 @@ +interface I { + proto p: string; +} diff --git a/packages/babylon/test/fixtures/flow/proto-props/interface/options.json b/packages/babylon/test/fixtures/flow/proto-props/interface/options.json new file mode 100644 index 0000000000..361b339318 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/proto-props/interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \":\" (2:8)" +} diff --git a/packages/babylon/test/fixtures/flow/proto-props/object/input.js b/packages/babylon/test/fixtures/flow/proto-props/object/input.js new file mode 100644 index 0000000000..c36795c854 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/proto-props/object/input.js @@ -0,0 +1 @@ +type T = { proto p: string } diff --git a/packages/babylon/test/fixtures/flow/proto-props/object/options.json b/packages/babylon/test/fixtures/flow/proto-props/object/options.json new file mode 100644 index 0000000000..9c1d71b48d --- /dev/null +++ b/packages/babylon/test/fixtures/flow/proto-props/object/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \":\" (1:17)" +} diff --git a/packages/babylon/test/fixtures/flow/proto-props/proto-static/input.js b/packages/babylon/test/fixtures/flow/proto-props/proto-static/input.js new file mode 100644 index 0000000000..1f03565c45 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/proto-props/proto-static/input.js @@ -0,0 +1,3 @@ +declare class C { + proto static p: T; +} diff --git a/packages/babylon/test/fixtures/flow/proto-props/proto-static/options.json b/packages/babylon/test/fixtures/flow/proto-props/proto-static/options.json new file mode 100644 index 0000000000..d691c5e8b4 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/proto-props/proto-static/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \":\" (2:15)" +} diff --git a/packages/babylon/test/fixtures/flow/proto-props/static-proto/input.js b/packages/babylon/test/fixtures/flow/proto-props/static-proto/input.js new file mode 100644 index 0000000000..86a4bc7703 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/proto-props/static-proto/input.js @@ -0,0 +1,3 @@ +declare class C { + static proto p: T; +} diff --git a/packages/babylon/test/fixtures/flow/proto-props/static-proto/options.json b/packages/babylon/test/fixtures/flow/proto-props/static-proto/options.json new file mode 100644 index 0000000000..d691c5e8b4 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/proto-props/static-proto/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \":\" (2:15)" +} diff --git a/scripts/tests/flow/flow_tests_whitelist.txt b/scripts/tests/flow/flow_tests_whitelist.txt index bba4ee86fe..89872e94e8 100644 --- a/scripts/tests/flow/flow_tests_whitelist.txt +++ b/scripts/tests/flow/flow_tests_whitelist.txt @@ -37,4 +37,3 @@ numbers/underscored_float_whole.js numbers/underscored_hex.js numbers/underscored_number.js numbers/underscored_oct.js -types/declare_class/proto.js