diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index 4f574776dc07..6382c1f6f3c2 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -463,7 +463,13 @@ export default (superClass: Class): Class => } while (this.eat(tt.comma)); } - node.body = this.flowParseObjectType(isClass, false, false, isClass); + node.body = this.flowParseObjectType({ + allowStatic: isClass, + allowExact: false, + allowSpread: false, + allowProto: isClass, + allowInexact: false, + }); } flowParseInterfaceExtends(): N.FlowInterfaceExtends { @@ -656,7 +662,13 @@ export default (superClass: Class): Class => } while (this.eat(tt.comma)); } - node.body = this.flowParseObjectType(false, false, false, false); + node.body = this.flowParseObjectType({ + allowStatic: false, + allowExact: false, + allowSpread: false, + allowProto: false, + allowInexact: false, + }); return this.finishNode(node, "InterfaceTypeAnnotation"); } @@ -754,12 +766,19 @@ export default (superClass: Class): Class => return this.finishNode(node, "ObjectTypeCallProperty"); } - flowParseObjectType( + flowParseObjectType({ + allowStatic, + allowExact, + allowSpread, + allowProto, + allowInexact, + }: { allowStatic: boolean, allowExact: boolean, allowSpread: boolean, allowProto: boolean, - ): N.FlowObjectTypeAnnotation { + allowInexact: boolean, + }): N.FlowObjectTypeAnnotation { const oldInType = this.state.inType; this.state.inType = true; @@ -772,6 +791,7 @@ export default (superClass: Class): Class => let endDelim; let exact; + let inexact = false; if (allowExact && this.match(tt.braceBarL)) { this.expect(tt.braceBarL); endDelim = tt.braceBarR; @@ -852,16 +872,21 @@ export default (superClass: Class): Class => } } - nodeStart.properties.push( - this.flowParseObjectTypeProperty( - node, - isStatic, - protoStart, - variance, - kind, - allowSpread, - ), + const propOrInexact = this.flowParseObjectTypeProperty( + node, + isStatic, + protoStart, + variance, + kind, + allowSpread, + allowInexact, ); + + if (propOrInexact === null) { + inexact = true; + } else { + nodeStart.properties.push(propOrInexact); + } } this.flowObjectTypeSemicolon(); @@ -869,6 +894,15 @@ export default (superClass: Class): Class => this.expect(endDelim); + /* The inexact flag should only be added on ObjectTypeAnnotations that + * are not the body of an interface, declare interface, or declare class. + * Since spreads are only allowed in objec types, checking that is + * sufficient here. + */ + if (allowSpread) { + nodeStart.inexact = inexact; + } + const out = this.finishNode(nodeStart, "ObjectTypeAnnotation"); this.state.inType = oldInType; @@ -883,7 +917,8 @@ export default (superClass: Class): Class => variance: ?N.FlowVariance, kind: string, allowSpread: boolean, - ): N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty { + allowInexact: boolean, + ): (N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty) | null { if (this.match(tt.ellipsis)) { if (!allowSpread) { this.unexpected( @@ -901,8 +936,30 @@ export default (superClass: Class): Class => ); } this.expect(tt.ellipsis); - node.argument = this.flowParseType(); + const isInexactToken = this.eat(tt.comma) || this.eat(tt.semi); + + if (this.match(tt.braceR)) { + if (allowInexact) return null; + this.unexpected( + null, + "Explicit inexact syntax is only allowed inside inexact objects", + ); + } + + if (this.match(tt.braceBarR)) { + this.unexpected( + null, + "Explicit inexact syntax cannot appear inside an explicit exact object type", + ); + } + if (isInexactToken) { + this.unexpected( + null, + "Explicit inexact syntax must appear at the end of an inexact object", + ); + } + node.argument = this.flowParseType(); return this.finishNode(node, "ObjectTypeSpreadProperty"); } else { node.key = this.flowParseObjectPropertyKey(); @@ -1146,10 +1203,22 @@ export default (superClass: Class): Class => ); case tt.braceL: - return this.flowParseObjectType(false, false, true, false); + return this.flowParseObjectType({ + allowStatic: false, + allowExact: false, + allowSpread: true, + allowProto: false, + allowInexact: true, + }); case tt.braceBarL: - return this.flowParseObjectType(false, true, true, false); + return this.flowParseObjectType({ + allowStatic: false, + allowExact: true, + allowSpread: true, + allowProto: false, + allowInexact: false, + }); case tt.bracketL: return this.flowParseTupleType(); diff --git a/packages/babel-parser/test/fixtures/flow/call-properties/1/output.json b/packages/babel-parser/test/fixtures/flow/call-properties/1/output.json index f106eb4dc399..41dbc2be1068 100644 --- a/packages/babel-parser/test/fixtures/flow/call-properties/1/output.json +++ b/packages/babel-parser/test/fixtures/flow/call-properties/1/output.json @@ -156,7 +156,8 @@ "properties": [], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, diff --git a/packages/babel-parser/test/fixtures/flow/call-properties/2/output.json b/packages/babel-parser/test/fixtures/flow/call-properties/2/output.json index bdd238b2985d..9b2e1c34ab13 100644 --- a/packages/babel-parser/test/fixtures/flow/call-properties/2/output.json +++ b/packages/babel-parser/test/fixtures/flow/call-properties/2/output.json @@ -156,7 +156,8 @@ "properties": [], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 b37fa6335539..edb622d15e0c 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 @@ -308,7 +308,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, diff --git a/packages/babel-parser/test/fixtures/flow/call-properties/4/output.json b/packages/babel-parser/test/fixtures/flow/call-properties/4/output.json index 6f1b515556c4..718dab31950f 100644 --- a/packages/babel-parser/test/fixtures/flow/call-properties/4/output.json +++ b/packages/babel-parser/test/fixtures/flow/call-properties/4/output.json @@ -256,7 +256,8 @@ "properties": [], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 81661e9066f7..0eb104082d54 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 @@ -239,7 +239,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], 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 3a740e6c1c30..5b41ff77f72a 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 @@ -239,7 +239,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], 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 563b25f29e43..84347d7d5618 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 @@ -146,7 +146,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } } 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 33f1898db552..e2a2f288cbb5 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 @@ -192,7 +192,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } } diff --git a/packages/babel-parser/test/fixtures/flow/declare-statements/14/output.json b/packages/babel-parser/test/fixtures/flow/declare-statements/14/output.json index b34f2531a1a7..a7b76763db42 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-statements/14/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-statements/14/output.json @@ -243,7 +243,8 @@ } ], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/def-site-variance/1/output.json b/packages/babel-parser/test/fixtures/flow/def-site-variance/1/output.json index 8455526f655d..938196ebcdb6 100644 --- a/packages/babel-parser/test/fixtures/flow/def-site-variance/1/output.json +++ b/packages/babel-parser/test/fixtures/flow/def-site-variance/1/output.json @@ -422,7 +422,8 @@ "properties": [], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/input.js new file mode 100644 index 000000000000..c3ef0ff53256 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/input.js @@ -0,0 +1,4 @@ +//@flow +declare class A { + ...; +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/options.json new file mode 100644 index 000000000000..c9188366d4e8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Spread operator cannot appear in class or interface definitions (3:2)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/input.js new file mode 100644 index 000000000000..fcc33d36c05b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/input.js @@ -0,0 +1,5 @@ +//@flow +declare class B { + foo: number; + ...; +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/options.json new file mode 100644 index 000000000000..658f8c434773 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Spread operator cannot appear in class or interface definitions (4:2)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/input.js new file mode 100644 index 000000000000..1f5df6b39ff9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/input.js @@ -0,0 +1,5 @@ +//@flow +declare class C { + ...; + foo: number; +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/options.json new file mode 100644 index 000000000000..c9188366d4e8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Spread operator cannot appear in class or interface definitions (3:2)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/input.js new file mode 100644 index 000000000000..7d0e44fc00c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/input.js @@ -0,0 +1,6 @@ +//@flow +declare class D { + foo: number; + ...; + bar: number; +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/options.json new file mode 100644 index 000000000000..658f8c434773 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Spread operator cannot appear in class or interface definitions (4:2)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/input.js new file mode 100644 index 000000000000..938efa8b5797 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/input.js @@ -0,0 +1,5 @@ +//@flow +interface F { + foo: number; + ...; +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/options.json new file mode 100644 index 000000000000..658f8c434773 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Spread operator cannot appear in class or interface definitions (4:2)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/input.js new file mode 100644 index 000000000000..59c4a399c358 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/input.js @@ -0,0 +1,5 @@ +//@flow +interface G { + ...; + foo: number; +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/options.json new file mode 100644 index 000000000000..c9188366d4e8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Spread operator cannot appear in class or interface definitions (3:2)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/input.js new file mode 100644 index 000000000000..4dde1fd3b04e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/input.js @@ -0,0 +1,6 @@ +//@flow +interface H { + foo: number; + ...; + bar: number; +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/options.json new file mode 100644 index 000000000000..658f8c434773 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Spread operator cannot appear in class or interface definitions (4:2)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/input.js new file mode 100644 index 000000000000..289513d4e480 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/input.js @@ -0,0 +1,2 @@ +//@flow +type T = {| foo: number, ... |} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/options.json new file mode 100644 index 000000000000..49936ac94990 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Explicit inexact syntax cannot appear inside an explicit exact object type (2:29)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/input.js new file mode 100644 index 000000000000..93c854cac282 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/input.js @@ -0,0 +1,2 @@ +//@flow +type T = {..., foo: number}; diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/options.json new file mode 100644 index 000000000000..ebb74417a527 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Explicit inexact syntax must appear at the end of an inexact object (2:15)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object/input.js new file mode 100644 index 000000000000..2fb3e7249593 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object/input.js @@ -0,0 +1,4 @@ +//@flow +type T = {...}; +type U = {x: number, ...}; +type V = {x: number, ...V, ...U}; diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object/output.json new file mode 100644 index 000000000000..7e32ace8159d --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object/output.json @@ -0,0 +1,437 @@ +{ + "type": "File", + "start": 0, + "end": 84, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 84, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 8, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": true + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + }, + { + "type": "TypeAlias", + "start": 24, + "end": 50, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 30, + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 + }, + "identifierName": "U" + }, + "name": "U" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 33, + "end": 49, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 34, + "end": 43, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "key": { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "x" + }, + "name": "x" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 19 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": true + } + }, + { + "type": "TypeAlias", + "start": 51, + "end": 84, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "id": { + "type": "Identifier", + "start": 56, + "end": 57, + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 6 + }, + "identifierName": "V" + }, + "name": "V" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 60, + "end": 83, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 61, + "end": 70, + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "key": { + "type": "Identifier", + "start": 61, + "end": 62, + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + }, + "identifierName": "x" + }, + "name": "x" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 64, + "end": 70, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + "variance": null, + "optional": false + }, + { + "type": "ObjectTypeSpreadProperty", + "start": 72, + "end": 76, + "loc": { + "start": { + "line": 4, + "column": 21 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "argument": { + "type": "GenericTypeAnnotation", + "start": 75, + "end": 76, + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 75, + "end": 76, + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 25 + }, + "identifierName": "V" + }, + "name": "V" + } + } + }, + { + "type": "ObjectTypeSpreadProperty", + "start": 78, + "end": 82, + "loc": { + "start": { + "line": 4, + "column": 27 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "argument": { + "type": "GenericTypeAnnotation", + "start": 81, + "end": 82, + "loc": { + "start": { + "line": 4, + "column": 30 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 81, + "end": 82, + "loc": { + "start": { + "line": 4, + "column": 30 + }, + "end": { + "line": 4, + "column": 31 + }, + "identifierName": "U" + }, + "name": "U" + } + } + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/input.js new file mode 100644 index 000000000000..84742c465959 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/input.js @@ -0,0 +1,2 @@ +//@flow +type T = {x: number, ..., y: number}; diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/options.json new file mode 100644 index 000000000000..6d703769bf61 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Explicit inexact syntax must appear at the end of an inexact object (2:26)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/input.js new file mode 100644 index 000000000000..15e4d01a74e6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/input.js @@ -0,0 +1,2 @@ +//@flow +type U = {x: number, ..., ...}; diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/options.json new file mode 100644 index 000000000000..6d703769bf61 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Explicit inexact syntax must appear at the end of an inexact object (2:26)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/input.js new file mode 100644 index 000000000000..d9037ecf24a3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/input.js @@ -0,0 +1,2 @@ +//@flow +type V = {x: number, ..., ...X}; diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/options.json new file mode 100644 index 000000000000..6d703769bf61 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/options.json @@ -0,0 +1,5 @@ +{ + "sourceType": "module", + "plugins": ["jsx", "flow"], + "throws": "Explicit inexact syntax must appear at the end of an inexact object (2:26)" +} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_trailing_comma/input.js b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_trailing_comma/input.js new file mode 100644 index 000000000000..2b439cf934f8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_trailing_comma/input.js @@ -0,0 +1,11 @@ +//@flow +type T = { ..., }; +type U = { ...; }; +type V = { + x: number, + ..., +}; +type W = { + x: number; + ...; +}; diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_trailing_comma/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_trailing_comma/output.json new file mode 100644 index 000000000000..3c39bdc107f5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_trailing_comma/output.json @@ -0,0 +1,395 @@ +{ + "type": "File", + "start": 0, + "end": 113, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 2 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 113, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 2 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 8, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 17, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": true + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + }, + { + "type": "TypeAlias", + "start": 27, + "end": 45, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 + }, + "identifierName": "U" + }, + "name": "U" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 36, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": true + } + }, + { + "type": "TypeAlias", + "start": 46, + "end": 79, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "id": { + "type": "Identifier", + "start": 51, + "end": 52, + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 6 + }, + "identifierName": "V" + }, + "name": "V" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 55, + "end": 78, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 59, + "end": 68, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "key": { + "type": "Identifier", + "start": 59, + "end": 60, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 62, + "end": 68, + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 11 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": true + } + }, + { + "type": "TypeAlias", + "start": 80, + "end": 113, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 11, + "column": 2 + } + }, + "id": { + "type": "Identifier", + "start": 85, + "end": 86, + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 8, + "column": 6 + }, + "identifierName": "W" + }, + "name": "W" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 89, + "end": 112, + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 11, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 93, + "end": 102, + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "key": { + "type": "Identifier", + "start": 93, + "end": 94, + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 96, + "end": 102, + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 11 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": true + } + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/internal-slot/object-method/output.json b/packages/babel-parser/test/fixtures/flow/internal-slot/object-method/output.json index 2be1cc35f8ee..b42f9eacce91 100644 --- a/packages/babel-parser/test/fixtures/flow/internal-slot/object-method/output.json +++ b/packages/babel-parser/test/fixtures/flow/internal-slot/object-method/output.json @@ -166,7 +166,8 @@ } } ], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/internal-slot/object-optional/output.json b/packages/babel-parser/test/fixtures/flow/internal-slot/object-optional/output.json index 9a422ace0dab..605db54c850a 100644 --- a/packages/babel-parser/test/fixtures/flow/internal-slot/object-optional/output.json +++ b/packages/babel-parser/test/fixtures/flow/internal-slot/object-optional/output.json @@ -148,7 +148,8 @@ } } ], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/internal-slot/object/output.json b/packages/babel-parser/test/fixtures/flow/internal-slot/object/output.json index dd474f9d3903..6ff31113bc57 100644 --- a/packages/babel-parser/test/fixtures/flow/internal-slot/object/output.json +++ b/packages/babel-parser/test/fixtures/flow/internal-slot/object/output.json @@ -147,7 +147,8 @@ } } ], - "exact": false + "exact": false, + "inexact": false } } ], 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 523dd9f5cbe4..865bb503288f 100644 --- a/packages/babel-parser/test/fixtures/flow/iterator/12/output.json +++ b/packages/babel-parser/test/fixtures/flow/iterator/12/output.json @@ -168,7 +168,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, "body": { 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 7162d07e7f7e..a21fcad31e10 100644 --- a/packages/babel-parser/test/fixtures/flow/iterator/13/output.json +++ b/packages/babel-parser/test/fixtures/flow/iterator/13/output.json @@ -168,7 +168,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, "body": { 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 4bd3e696e5d6..c6357989dc29 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 @@ -233,7 +233,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], 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 c7bc62245446..a1ff7e2786c1 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 @@ -153,7 +153,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false }, { "type": "ObjectTypeAnnotation", @@ -232,7 +233,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } ] } @@ -626,7 +628,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false }, { "type": "ObjectTypeAnnotation", @@ -705,7 +708,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } ] }, @@ -715,7 +719,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, { @@ -893,7 +898,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false }, { "type": "ObjectTypeAnnotation", @@ -972,7 +978,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } ] }, @@ -982,7 +989,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], 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 59d32d37d0fb..a3e8ba642bf2 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 @@ -213,7 +213,8 @@ ], "indexers": [], "internalSlots": [], - "exact": true + "exact": true, + "inexact": false } } }, @@ -532,7 +533,8 @@ ], "indexers": [], "internalSlots": [], - "exact": true + "exact": true, + "inexact": false } } }, @@ -744,7 +746,8 @@ "properties": [], "indexers": [], "internalSlots": [], - "exact": true + "exact": true, + "inexact": false } } }, @@ -1003,7 +1006,8 @@ ], "indexers": [], "internalSlots": [], - "exact": true + "exact": true, + "inexact": false }, "variance": null, "optional": false @@ -1064,7 +1068,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, @@ -1537,7 +1542,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false }, "variance": null, "optional": false @@ -1598,7 +1604,8 @@ ], "indexers": [], "internalSlots": [], - "exact": true + "exact": true, + "inexact": false } } }, 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 4929bc3d478f..4b3587d4c8a8 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 @@ -166,7 +166,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], 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 afb693e33614..ec02ec57394d 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 @@ -166,7 +166,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/114/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/114/output.json index 0cb28d6e0fd3..ed6301370237 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/114/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/114/output.json @@ -195,7 +195,8 @@ } ], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/115/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/115/output.json index da040897ade4..df1f40c30646 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/115/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/115/output.json @@ -195,7 +195,8 @@ } ], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/127/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/127/output.json index 4d08cf624407..165aac2e4caa 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/127/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/127/output.json @@ -128,7 +128,8 @@ } ], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/128/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/128/output.json index cf23e569d27c..345675c7e135 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/128/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/128/output.json @@ -160,7 +160,8 @@ } ], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/135/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/135/output.json index aa8891c0b701..ce7e04fe7836 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/135/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/135/output.json @@ -110,7 +110,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], 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 f2a1f069cffc..bdd81eaa2c09 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 @@ -130,7 +130,8 @@ "properties": [], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false }, "variance": null, "optional": false @@ -167,13 +168,15 @@ "properties": [], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/138/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/138/output.json index 1987550217b1..6e48beeb05dc 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/138/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/138/output.json @@ -276,7 +276,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/16/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/16/output.json index 4db03aa8f5aa..59fe3a8d364e 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/16/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/16/output.json @@ -96,7 +96,8 @@ "properties": [], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, "body": { 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 6e85ab61db4e..70cbbd4fef08 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 @@ -160,7 +160,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 5b4664821d6c..1ef29b3b8bb6 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 @@ -160,7 +160,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 e0cef862f368..b389c49201ad 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 @@ -225,7 +225,8 @@ } ], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 42d9e07ef5fd..cc227490d30a 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 @@ -174,7 +174,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } } 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 fee4f6be4559..431aa501bc4d 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 @@ -213,7 +213,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 24897a890d17..428bb08cb9aa 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 @@ -211,7 +211,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false }, "variance": null, "optional": false @@ -219,7 +220,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 537525fd5058..0e133ba1cfbc 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 @@ -225,7 +225,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, "variance": null, @@ -234,7 +235,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 fe3cbacc4b91..03cc703ab871 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 @@ -213,7 +213,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 ed33244fe9cb..2cfc8de95973 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 @@ -213,7 +213,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/41/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/41/output.json index 9e2c759153b9..2f073e822eff 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/41/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/41/output.json @@ -235,7 +235,8 @@ } ], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 446275326eff..b918a1e51b0a 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 @@ -322,7 +322,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 027091719c88..05ff2466b98b 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 @@ -295,7 +295,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 1f013f7840a1..cfa5f6db54cc 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 @@ -215,7 +215,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 c26e02abf8ad..25d46071b872 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 @@ -215,7 +215,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 7311b8c2411e..e9fb827b5b7d 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 @@ -220,7 +220,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } } 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 669cab2fd5e9..6a24cf2f1e35 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 @@ -266,7 +266,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } }, 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 61c974a71802..f72e8ff175f2 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 @@ -151,7 +151,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, { @@ -309,7 +310,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, { @@ -433,7 +435,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, { @@ -590,7 +593,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, { @@ -693,7 +697,8 @@ "properties": [], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, { @@ -896,7 +901,8 @@ "properties": [], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, { 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 0b9e5fd724bd..d817f6ed4713 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 @@ -492,7 +492,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } } ], 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 45638f476d7a..4d9f9da74bf5 100644 --- a/packages/babel-parser/test/fixtures/flow/typecasts/2/output.json +++ b/packages/babel-parser/test/fixtures/flow/typecasts/2/output.json @@ -323,7 +323,8 @@ ], "indexers": [], "internalSlots": [], - "exact": false + "exact": false, + "inexact": false } }, "extra": { diff --git a/packages/babel-types/src/definitions/flow.js b/packages/babel-types/src/definitions/flow.js index fa4ad6e52d4c..bb08e9112aac 100644 --- a/packages/babel-types/src/definitions/flow.js +++ b/packages/babel-types/src/definitions/flow.js @@ -277,6 +277,10 @@ defineType("ObjectTypeAnnotation", { validate: assertValueType("boolean"), default: false, }, + // If the inexact flag is present then this is an object type, and not a + // declare class, declare interface, or interface. If it is true, the + // object uses ... to express that it is inexact. + inexact: validateOptional(assertValueType("boolean")), }, });