From f5ef928586f592aa2d8bb60120ae58833d17e0db Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Mon, 11 Dec 2017 09:32:16 -0600 Subject: [PATCH] Add method property to ObjectTypeProperty (#7005) --- Makefile | 2 +- .../babel-generator/src/generators/flow.js | 9 +- .../fixtures/flow/declare-exports/expected.js | 2 +- .../fixtures/flow/declare-module/expected.js | 6 +- .../flow/declare-statements/expected.js | 2 +- .../flow/object-literal-types/actual.js | 4 +- .../flow/object-literal-types/expected.js | 8 +- .../flow/type-annotations/expected.js | 10 +- packages/babylon/src/plugins/flow.js | 5 + .../flow/call-properties/3/expected.json | 1 + .../getter-setter/expected.json | 6 + .../named-static/expected.json | 1 + .../declare-export/export-class/expected.json | 1 + .../flow/declare-module/10/expected.json | 1 + .../flow/declare-module/5/expected.json | 1 + .../flow/declare-module/6/expected.json | 1 + .../flow/declare-statements/10/expected.json | 2 + .../flow/declare-statements/15/expected.json | 2 + .../flow/declare-statements/17/expected.json | 3 + .../flow/declare-statements/7/expected.json | 1 + .../flow/declare-statements/9/expected.json | 1 + .../10/expected.json | 2 + .../4/expected.json | 1 + .../5/expected.json | 1 + .../complex-param-types/expected.json | 1 + .../fixtures/flow/type-alias/4/expected.json | 8 + .../flow/type-annotations/108/expected.json | 12 + .../flow/type-annotations/110/expected.json | 1 + .../flow/type-annotations/111/expected.json | 1 + .../flow/type-annotations/136/expected.json | 1 + .../flow/type-annotations/32/expected.json | 1 + .../flow/type-annotations/33/expected.json | 1 + .../flow/type-annotations/34/expected.json | 1 + .../flow/type-annotations/35/expected.json | 1 + .../flow/type-annotations/36/expected.json | 2 + .../flow/type-annotations/37/expected.json | 2 + .../flow/type-annotations/38/expected.json | 2 + .../flow/type-annotations/39/expected.json | 2 + .../flow/type-annotations/40/expected.json | 2 + .../flow/type-annotations/42/expected.json | 1 + .../flow/type-annotations/43/expected.json | 1 + .../flow/type-annotations/60/expected.json | 1 + .../flow/type-annotations/61/expected.json | 1 + .../flow/type-annotations/63/expected.json | 1 + .../flow/type-annotations/98/expected.json | 3 + .../object-type-method/actual.js | 12 + .../object-type-method/expected.json | 1350 +++++++++++++++++ .../flow/type-exports/interface/expected.json | 2 + .../expected.json | 8 + .../expected.json | 4 + .../interface-reserved-word/expected.json | 4 + .../type-object-reserved-word/expected.json | 4 + .../fixtures/flow/typecasts/2/expected.json | 2 + scripts/tests/flow/flow_tests_whitelist.txt | 2 + 54 files changed, 1491 insertions(+), 16 deletions(-) create mode 100644 packages/babylon/test/fixtures/flow/type-annotations/object-type-method/actual.js create mode 100644 packages/babylon/test/fixtures/flow/type-annotations/object-type-method/expected.json diff --git a/Makefile b/Makefile index 70cb2b921e..9f07ae0e2e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ MAKEFLAGS = -j1 -FLOW_COMMIT = 0dfdb8bf984205f03e95b71680e39bae6b8f7066 +FLOW_COMMIT = 622bbc4f07acb77eb1109830c70815f827401d90 TEST262_COMMIT = 1282e842febf418ca27df13fa4b32f7e5021b470 export NODE_ENV = test diff --git a/packages/babel-generator/src/generators/flow.js b/packages/babel-generator/src/generators/flow.js index be6ef45498..156c0114ec 100644 --- a/packages/babel-generator/src/generators/flow.js +++ b/packages/babel-generator/src/generators/flow.js @@ -182,7 +182,8 @@ export function FunctionTypeAnnotation(node: Object, parent: Object) { // this node type is overloaded, not sure why but it makes it EXTREMELY annoying if ( parent.type === "ObjectTypeCallProperty" || - parent.type === "DeclareFunction" + parent.type === "DeclareFunction" || + (parent.type === "ObjectTypeProperty" && parent.method) ) { this.token(":"); } else { @@ -437,8 +438,10 @@ export function ObjectTypeProperty(node: Object) { this._variance(node); this.print(node.key, node); if (node.optional) this.token("?"); - this.token(":"); - this.space(); + if (!node.method) { + this.token(":"); + this.space(); + } this.print(node.value, node); } diff --git a/packages/babel-generator/test/fixtures/flow/declare-exports/expected.js b/packages/babel-generator/test/fixtures/flow/declare-exports/expected.js index 4cf54c307b..1b1cf155a2 100644 --- a/packages/babel-generator/test/fixtures/flow/declare-exports/expected.js +++ b/packages/babel-generator/test/fixtures/flow/declare-exports/expected.js @@ -9,7 +9,7 @@ declare export class A extends B { x: number } declare export class A { - static foo: () => number, + static foo(): number, static x: string, } declare export class A { diff --git a/packages/babel-generator/test/fixtures/flow/declare-module/expected.js b/packages/babel-generator/test/fixtures/flow/declare-module/expected.js index f464ea7a0f..9fc62c7edf 100644 --- a/packages/babel-generator/test/fixtures/flow/declare-module/expected.js +++ b/packages/babel-generator/test/fixtures/flow/declare-module/expected.js @@ -8,11 +8,11 @@ declare module A { } declare module A { declare class B { - foo: () => number + foo(): number } } declare module A { declare module.exports: { - foo: () => number + foo(): number } -} \ No newline at end of file +} diff --git a/packages/babel-generator/test/fixtures/flow/declare-statements/expected.js b/packages/babel-generator/test/fixtures/flow/declare-statements/expected.js index d186a7ab19..674b66daa2 100644 --- a/packages/babel-generator/test/fixtures/flow/declare-statements/expected.js +++ b/packages/babel-generator/test/fixtures/flow/declare-statements/expected.js @@ -9,7 +9,7 @@ declare class A extends B { x: number } declare class A { - static foo: () => number, + static foo(): number, static x: string, } declare class A { diff --git a/packages/babel-generator/test/fixtures/flow/object-literal-types/actual.js b/packages/babel-generator/test/fixtures/flow/object-literal-types/actual.js index 80d29c99ee..e7c44cbd0f 100644 --- a/packages/babel-generator/test/fixtures/flow/object-literal-types/actual.js +++ b/packages/babel-generator/test/fixtures/flow/object-literal-types/actual.js @@ -4,4 +4,6 @@ type T = { ...U, }; type T = { ...U, ...V }; type T = { p: V, ...U }; type T = { ...U, p: V, }; -type T = { ...{}|{ p: V, }}; \ No newline at end of file +type T = { ...{}|{ p: V, }}; +type T = { foo(): number } +type T = { foo: () => number } diff --git a/packages/babel-generator/test/fixtures/flow/object-literal-types/expected.js b/packages/babel-generator/test/fixtures/flow/object-literal-types/expected.js index d54c31b865..4eb91613ba 100644 --- a/packages/babel-generator/test/fixtures/flow/object-literal-types/expected.js +++ b/packages/babel-generator/test/fixtures/flow/object-literal-types/expected.js @@ -15,4 +15,10 @@ type T = { ...U, type T = { ...{} | { p: V } -}; \ No newline at end of file +}; +type T = { + foo(): number +}; +type T = { + foo: () => number +}; diff --git a/packages/babel-generator/test/fixtures/flow/type-annotations/expected.js b/packages/babel-generator/test/fixtures/flow/type-annotations/expected.js index 664a182464..c86dca2e60 100644 --- a/packages/babel-generator/test/fixtures/flow/type-annotations/expected.js +++ b/packages/babel-generator/test/fixtures/flow/type-annotations/expected.js @@ -126,13 +126,13 @@ var a: { [b: number]: string, }; var a: { - add: (x: number, ...y: Array) => void + add(x: number, ...y: Array): void }; var a: { subtract: (x: number, ...y: Array) => void }; var a: { - id: (x: T) => T + id(x: T): T }; var a: Array = [1, 2, 3]; a = class Foo {}; @@ -275,17 +275,17 @@ var a: {| [b: number]: string, |}; var a: {| - add: (x: number, ...y: Array) => void + add(x: number, ...y: Array): void |}; var a: {| subtract: (x: number, ...y: Array) => void |}; var a: {| - id: (x: T) => T + id(x: T): T |}; function foo(numVal: number = 2) {} function foo(numVal?: number = 2) {} -export type * from "foo"; \ No newline at end of file +export type * from "foo"; diff --git a/packages/babylon/src/plugins/flow.js b/packages/babylon/src/plugins/flow.js index 2a22df5bef..a8bf59ccb7 100644 --- a/packages/babylon/src/plugins/flow.js +++ b/packages/babylon/src/plugins/flow.js @@ -751,6 +751,8 @@ export default (superClass: Class): Class => let optional = false; if (this.isRelational("<") || this.match(tt.parenL)) { // This is a method property + node.method = true; + if (variance) { this.unexpected(variance.start); } @@ -763,6 +765,9 @@ export default (superClass: Class): Class => } } else { if (kind !== "init") this.unexpected(); + + node.method = false; + if (this.eat(tt.question)) { optional = true; } diff --git a/packages/babylon/test/fixtures/flow/call-properties/3/expected.json b/packages/babylon/test/fixtures/flow/call-properties/3/expected.json index acd2bf6782..fdc92e6b2b 100644 --- a/packages/babylon/test/fixtures/flow/call-properties/3/expected.json +++ b/packages/babylon/test/fixtures/flow/call-properties/3/expected.json @@ -284,6 +284,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 25, diff --git a/packages/babylon/test/fixtures/flow/class-properties/getter-setter/expected.json b/packages/babylon/test/fixtures/flow/class-properties/getter-setter/expected.json index 13744ddb93..d2e591f280 100644 --- a/packages/babylon/test/fixtures/flow/class-properties/getter-setter/expected.json +++ b/packages/babylon/test/fixtures/flow/class-properties/getter-setter/expected.json @@ -111,6 +111,7 @@ }, "static": false, "kind": "get", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 20, @@ -179,6 +180,7 @@ }, "static": false, "kind": "set", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 39, @@ -299,6 +301,7 @@ }, "static": false, "kind": "get", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 65, @@ -370,6 +373,7 @@ }, "static": false, "kind": "set", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 86, @@ -490,6 +494,7 @@ }, "static": false, "kind": "get", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 114, @@ -561,6 +566,7 @@ }, "static": false, "kind": "set", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 133, diff --git a/packages/babylon/test/fixtures/flow/class-properties/named-static/expected.json b/packages/babylon/test/fixtures/flow/class-properties/named-static/expected.json index eea8e7d6a6..bdec47c1a5 100644 --- a/packages/babylon/test/fixtures/flow/class-properties/named-static/expected.json +++ b/packages/babylon/test/fixtures/flow/class-properties/named-static/expected.json @@ -111,6 +111,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "GenericTypeAnnotation", "start": 28, diff --git a/packages/babylon/test/fixtures/flow/declare-export/export-class/expected.json b/packages/babylon/test/fixtures/flow/declare-export/export-class/expected.json index d403da0296..4150ba6490 100644 --- a/packages/babylon/test/fixtures/flow/declare-export/export-class/expected.json +++ b/packages/babylon/test/fixtures/flow/declare-export/export-class/expected.json @@ -174,6 +174,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 50, diff --git a/packages/babylon/test/fixtures/flow/declare-module/10/expected.json b/packages/babylon/test/fixtures/flow/declare-module/10/expected.json index 5b28d3a95c..36bd707144 100644 --- a/packages/babylon/test/fixtures/flow/declare-module/10/expected.json +++ b/packages/babylon/test/fixtures/flow/declare-module/10/expected.json @@ -105,6 +105,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 26, diff --git a/packages/babylon/test/fixtures/flow/declare-module/5/expected.json b/packages/babylon/test/fixtures/flow/declare-module/5/expected.json index d6491c6f37..80be55a8c3 100644 --- a/packages/babylon/test/fixtures/flow/declare-module/5/expected.json +++ b/packages/babylon/test/fixtures/flow/declare-module/5/expected.json @@ -157,6 +157,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 37, diff --git a/packages/babylon/test/fixtures/flow/declare-module/6/expected.json b/packages/babylon/test/fixtures/flow/declare-module/6/expected.json index 7b1772c283..c96803274c 100644 --- a/packages/babylon/test/fixtures/flow/declare-module/6/expected.json +++ b/packages/babylon/test/fixtures/flow/declare-module/6/expected.json @@ -151,6 +151,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 45, diff --git a/packages/babylon/test/fixtures/flow/declare-statements/10/expected.json b/packages/babylon/test/fixtures/flow/declare-statements/10/expected.json index 378c963659..5342db2957 100644 --- a/packages/babylon/test/fixtures/flow/declare-statements/10/expected.json +++ b/packages/babylon/test/fixtures/flow/declare-statements/10/expected.json @@ -111,6 +111,7 @@ }, "static": true, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 18, @@ -179,6 +180,7 @@ }, "static": true, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 51, diff --git a/packages/babylon/test/fixtures/flow/declare-statements/15/expected.json b/packages/babylon/test/fixtures/flow/declare-statements/15/expected.json index 6b3d9f0b04..b1cffdd603 100644 --- a/packages/babylon/test/fixtures/flow/declare-statements/15/expected.json +++ b/packages/babylon/test/fixtures/flow/declare-statements/15/expected.json @@ -111,6 +111,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 27, @@ -250,6 +251,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "GenericTypeAnnotation", "start": 66, diff --git a/packages/babylon/test/fixtures/flow/declare-statements/17/expected.json b/packages/babylon/test/fixtures/flow/declare-statements/17/expected.json index 2f4a6dc1cb..3f679259e7 100644 --- a/packages/babylon/test/fixtures/flow/declare-statements/17/expected.json +++ b/packages/babylon/test/fixtures/flow/declare-statements/17/expected.json @@ -111,6 +111,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 22, @@ -162,6 +163,7 @@ }, "static": true, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 41, @@ -213,6 +215,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 53, diff --git a/packages/babylon/test/fixtures/flow/declare-statements/7/expected.json b/packages/babylon/test/fixtures/flow/declare-statements/7/expected.json index babd12a4f5..41df008a59 100644 --- a/packages/babylon/test/fixtures/flow/declare-statements/7/expected.json +++ b/packages/babylon/test/fixtures/flow/declare-statements/7/expected.json @@ -111,6 +111,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 29, diff --git a/packages/babylon/test/fixtures/flow/declare-statements/9/expected.json b/packages/babylon/test/fixtures/flow/declare-statements/9/expected.json index 3bafe9b3ab..5c887c2d78 100644 --- a/packages/babylon/test/fixtures/flow/declare-statements/9/expected.json +++ b/packages/babylon/test/fixtures/flow/declare-statements/9/expected.json @@ -227,6 +227,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 37, diff --git a/packages/babylon/test/fixtures/flow/interfaces-module-and-script/10/expected.json b/packages/babylon/test/fixtures/flow/interfaces-module-and-script/10/expected.json index 4fb5918fb1..1260b7fcbb 100644 --- a/packages/babylon/test/fixtures/flow/interfaces-module-and-script/10/expected.json +++ b/packages/babylon/test/fixtures/flow/interfaces-module-and-script/10/expected.json @@ -161,6 +161,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "BooleanTypeAnnotation", "start": 22, @@ -212,6 +213,7 @@ }, "static": true, "kind": "init", + "method": false, "value": { "type": "BooleanTypeAnnotation", "start": 62, diff --git a/packages/babylon/test/fixtures/flow/interfaces-module-and-script/4/expected.json b/packages/babylon/test/fixtures/flow/interfaces-module-and-script/4/expected.json index 83636e0555..492840fe45 100644 --- a/packages/babylon/test/fixtures/flow/interfaces-module-and-script/4/expected.json +++ b/packages/babylon/test/fixtures/flow/interfaces-module-and-script/4/expected.json @@ -111,6 +111,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "FunctionTypeAnnotation", "start": 19, diff --git a/packages/babylon/test/fixtures/flow/interfaces-module-and-script/5/expected.json b/packages/babylon/test/fixtures/flow/interfaces-module-and-script/5/expected.json index da45e73fc6..5076c34a90 100644 --- a/packages/babylon/test/fixtures/flow/interfaces-module-and-script/5/expected.json +++ b/packages/babylon/test/fixtures/flow/interfaces-module-and-script/5/expected.json @@ -111,6 +111,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 56, diff --git a/packages/babylon/test/fixtures/flow/object-types/complex-param-types/expected.json b/packages/babylon/test/fixtures/flow/object-types/complex-param-types/expected.json index 9665529d8d..f74a8e1c53 100644 --- a/packages/babylon/test/fixtures/flow/object-types/complex-param-types/expected.json +++ b/packages/babylon/test/fixtures/flow/object-types/complex-param-types/expected.json @@ -109,6 +109,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 11, diff --git a/packages/babylon/test/fixtures/flow/type-alias/4/expected.json b/packages/babylon/test/fixtures/flow/type-alias/4/expected.json index c45c0020b6..549a3e9f02 100644 --- a/packages/babylon/test/fixtures/flow/type-alias/4/expected.json +++ b/packages/babylon/test/fixtures/flow/type-alias/4/expected.json @@ -124,6 +124,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringLiteralTypeAnnotation", "start": 23, @@ -200,6 +201,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringLiteralTypeAnnotation", "start": 38, @@ -525,6 +527,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "UnionTypeAnnotation", "start": 147, @@ -589,6 +592,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringLiteralTypeAnnotation", "start": 156, @@ -665,6 +669,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringLiteralTypeAnnotation", "start": 174, @@ -783,6 +788,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "IntersectionTypeAnnotation", "start": 212, @@ -847,6 +853,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringLiteralTypeAnnotation", "start": 221, @@ -923,6 +930,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringLiteralTypeAnnotation", "start": 239, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/108/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/108/expected.json index 33daa2c034..635352a145 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/108/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/108/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 14, @@ -187,6 +188,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 25, @@ -450,6 +452,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 71, @@ -501,6 +504,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 82, @@ -864,6 +868,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "ObjectTypeAnnotation", "start": 148, @@ -913,6 +918,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 154, @@ -964,6 +970,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 165, @@ -1022,6 +1029,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "BooleanTypeAnnotation", "start": 179, @@ -1388,6 +1396,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "ObjectTypeAnnotation", "start": 242, @@ -1437,6 +1446,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 247, @@ -1488,6 +1498,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 258, @@ -1546,6 +1557,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "BooleanTypeAnnotation", "start": 271, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/110/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/110/expected.json index 063bbf7e97..5942b598e2 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/110/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/110/expected.json @@ -109,6 +109,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "GenericTypeAnnotation", "start": 13, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/111/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/111/expected.json index 02766a4758..4b3f7042a0 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/111/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/111/expected.json @@ -109,6 +109,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "GenericTypeAnnotation", "start": 13, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/136/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/136/expected.json index 6ccd7002c9..c3b6a7458f 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/136/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/136/expected.json @@ -109,6 +109,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "ObjectTypeAnnotation", "start": 15, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/32/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/32/expected.json index 2009fe86e1..200e435106 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/32/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/32/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 16, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/33/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/33/expected.json index 20c064ef1a..b40e6d268f 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/33/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/33/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 16, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/34/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/34/expected.json index 8214472aee..5862b60835 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/34/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/34/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 16, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/35/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/35/expected.json index 0a016d2518..0a41ba7cef 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/35/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/35/expected.json @@ -150,6 +150,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 17, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/36/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/36/expected.json index 31e1d58d02..9903698b23 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/36/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/36/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 16, @@ -187,6 +188,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 32, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/37/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/37/expected.json index 5c4dbc804f..a46c2ceedc 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/37/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/37/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "ObjectTypeAnnotation", "start": 16, @@ -185,6 +186,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 25, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/38/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/38/expected.json index 13365bd73e..ee23ab7c2f 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/38/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/38/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NullableTypeAnnotation", "start": 16, @@ -199,6 +200,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 26, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/39/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/39/expected.json index ff7898371e..1fcd44b9c3 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/39/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/39/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 16, @@ -187,6 +188,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 32, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/40/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/40/expected.json index fc457a1df3..a50f10e2c5 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/40/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/40/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 16, @@ -187,6 +188,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 33, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/42/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/42/expected.json index 71e3447c35..2d89613fa7 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/42/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/42/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 8, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/43/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/43/expected.json index 07ba5008e4..92e7df5a44 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/43/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/43/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 9, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/60/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/60/expected.json index 984fb4515b..c511b67445 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/60/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/60/expected.json @@ -191,6 +191,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 13, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/61/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/61/expected.json index d5033f3c84..75d358a1f5 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/61/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/61/expected.json @@ -191,6 +191,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 13, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/63/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/63/expected.json index e985f1ee8c..0c192add98 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/63/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/63/expected.json @@ -196,6 +196,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 23, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/98/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/98/expected.json index 0b51971251..f5f36f3a7d 100644 --- a/packages/babylon/test/fixtures/flow/type-annotations/98/expected.json +++ b/packages/babylon/test/fixtures/flow/type-annotations/98/expected.json @@ -136,6 +136,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 17, @@ -187,6 +188,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 33, @@ -238,6 +240,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 49, diff --git a/packages/babylon/test/fixtures/flow/type-annotations/object-type-method/actual.js b/packages/babylon/test/fixtures/flow/type-annotations/object-type-method/actual.js new file mode 100644 index 0000000000..216a4222b3 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/type-annotations/object-type-method/actual.js @@ -0,0 +1,12 @@ +type T = { a: () => void }; +type T = { a: () => void }; +type T = { a(): void }; +type T = { a(): void }; + +type T = { (): number }; +type T = { (x: T): number; } + +declare class T { foo(): number; } +declare class T { static foo(): number; } +declare class T { (): number } +declare class T { static (): number } diff --git a/packages/babylon/test/fixtures/flow/type-annotations/object-type-method/expected.json b/packages/babylon/test/fixtures/flow/type-annotations/object-type-method/expected.json new file mode 100644 index 0000000000..aefcaa1c07 --- /dev/null +++ b/packages/babylon/test/fixtures/flow/type-annotations/object-type-method/expected.json @@ -0,0 +1,1350 @@ +{ + "type": "File", + "start": 0, + "end": 314, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 12, + "column": 37 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 314, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 12, + "column": 37 + } + }, + "sourceType": "module", + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 11, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "key": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + }, + "static": false, + "kind": "init", + "method": false, + "value": { + "type": "FunctionTypeAnnotation", + "start": 14, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "params": [], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 20, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 24 + } + } + }, + "typeParameters": null + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "exact": false + } + }, + { + "type": "TypeAlias", + "start": 28, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 33, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 37, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 39, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "key": { + "type": "Identifier", + "start": 39, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + }, + "static": false, + "kind": "init", + "method": false, + "value": { + "type": "FunctionTypeAnnotation", + "start": 42, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "typeParameters": { + "type": "TypeParameterDeclaration", + "start": 42, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "params": [ + { + "type": "TypeParameter", + "start": 43, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "name": "T", + "variance": null + } + ] + }, + "params": [], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 51, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 27 + } + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "exact": false + } + }, + { + "type": "TypeAlias", + "start": 59, + "end": 82, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "id": { + "type": "Identifier", + "start": 64, + "end": 65, + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 68, + "end": 81, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 70, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "key": { + "type": "Identifier", + "start": 70, + "end": 71, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + }, + "static": false, + "kind": "init", + "method": true, + "value": { + "type": "FunctionTypeAnnotation", + "start": 70, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "params": [], + "rest": null, + "typeParameters": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 75, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 20 + } + } + } + }, + "optional": false + } + ], + "indexers": [], + "exact": false + } + }, + { + "type": "TypeAlias", + "start": 83, + "end": 109, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 88, + "end": 89, + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 92, + "end": 108, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 94, + "end": 106, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "key": { + "type": "Identifier", + "start": 94, + "end": 95, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + }, + "static": false, + "kind": "init", + "method": true, + "value": { + "type": "FunctionTypeAnnotation", + "start": 94, + "end": 106, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "params": [], + "rest": null, + "typeParameters": { + "type": "TypeParameterDeclaration", + "start": 95, + "end": 98, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "params": [ + { + "type": "TypeParameter", + "start": 96, + "end": 97, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "name": "T", + "variance": null + } + ] + }, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 102, + "end": 106, + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + } + } + }, + "optional": false + } + ], + "indexers": [], + "exact": false + } + }, + { + "type": "TypeAlias", + "start": 111, + "end": 135, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 116, + "end": 117, + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 120, + "end": 134, + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 23 + } + }, + "callProperties": [ + { + "type": "ObjectTypeCallProperty", + "start": 122, + "end": 132, + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 21 + } + }, + "static": false, + "value": { + "type": "FunctionTypeAnnotation", + "start": 122, + "end": 132, + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 21 + } + }, + "params": [], + "rest": null, + "typeParameters": null, + "returnType": { + "type": "NumberTypeAnnotation", + "start": 126, + "end": 132, + "loc": { + "start": { + "line": 6, + "column": 15 + }, + "end": { + "line": 6, + "column": 21 + } + } + } + } + } + ], + "properties": [], + "indexers": [], + "exact": false + } + }, + { + "type": "TypeAlias", + "start": 136, + "end": 167, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 31 + } + }, + "id": { + "type": "Identifier", + "start": 141, + "end": 142, + "loc": { + "start": { + "line": 7, + "column": 5 + }, + "end": { + "line": 7, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 145, + "end": 167, + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 31 + } + }, + "callProperties": [ + { + "type": "ObjectTypeCallProperty", + "start": 147, + "end": 164, + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 28 + } + }, + "static": false, + "value": { + "type": "FunctionTypeAnnotation", + "start": 147, + "end": 164, + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 28 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 151, + "end": 155, + "loc": { + "start": { + "line": 7, + "column": 15 + }, + "end": { + "line": 7, + "column": 19 + } + }, + "name": { + "type": "Identifier", + "start": 151, + "end": 152, + "loc": { + "start": { + "line": 7, + "column": 15 + }, + "end": { + "line": 7, + "column": 16 + }, + "identifierName": "x" + }, + "name": "x" + }, + "optional": false, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 154, + "end": 155, + "loc": { + "start": { + "line": 7, + "column": 18 + }, + "end": { + "line": 7, + "column": 19 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 154, + "end": 155, + "loc": { + "start": { + "line": 7, + "column": 18 + }, + "end": { + "line": 7, + "column": 19 + }, + "identifierName": "T" + }, + "name": "T" + } + } + } + ], + "rest": null, + "typeParameters": { + "type": "TypeParameterDeclaration", + "start": 147, + "end": 150, + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 14 + } + }, + "params": [ + { + "type": "TypeParameter", + "start": 148, + "end": 149, + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 13 + } + }, + "name": "T", + "variance": null + } + ] + }, + "returnType": { + "type": "NumberTypeAnnotation", + "start": 158, + "end": 164, + "loc": { + "start": { + "line": 7, + "column": 22 + }, + "end": { + "line": 7, + "column": 28 + } + } + } + } + } + ], + "properties": [], + "indexers": [], + "exact": false + } + }, + { + "type": "DeclareClass", + "start": 169, + "end": 203, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 183, + "end": 184, + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 15 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "extends": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 185, + "end": 203, + "loc": { + "start": { + "line": 9, + "column": 16 + }, + "end": { + "line": 9, + "column": 34 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 187, + "end": 200, + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 31 + } + }, + "key": { + "type": "Identifier", + "start": 187, + "end": 190, + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 21 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "static": false, + "kind": "init", + "method": true, + "value": { + "type": "FunctionTypeAnnotation", + "start": 187, + "end": 200, + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 31 + } + }, + "params": [], + "rest": null, + "typeParameters": null, + "returnType": { + "type": "NumberTypeAnnotation", + "start": 194, + "end": 200, + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 31 + } + } + } + }, + "optional": false + } + ], + "indexers": [], + "exact": false + } + }, + { + "type": "DeclareClass", + "start": 204, + "end": 245, + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 218, + "end": 219, + "loc": { + "start": { + "line": 10, + "column": 14 + }, + "end": { + "line": 10, + "column": 15 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "extends": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 220, + "end": 245, + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 41 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 222, + "end": 242, + "loc": { + "start": { + "line": 10, + "column": 18 + }, + "end": { + "line": 10, + "column": 38 + } + }, + "key": { + "type": "Identifier", + "start": 229, + "end": 232, + "loc": { + "start": { + "line": 10, + "column": 25 + }, + "end": { + "line": 10, + "column": 28 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "static": true, + "kind": "init", + "method": true, + "value": { + "type": "FunctionTypeAnnotation", + "start": 222, + "end": 242, + "loc": { + "start": { + "line": 10, + "column": 18 + }, + "end": { + "line": 10, + "column": 38 + } + }, + "params": [], + "rest": null, + "typeParameters": null, + "returnType": { + "type": "NumberTypeAnnotation", + "start": 236, + "end": 242, + "loc": { + "start": { + "line": 10, + "column": 32 + }, + "end": { + "line": 10, + "column": 38 + } + } + } + }, + "optional": false + } + ], + "indexers": [], + "exact": false + } + }, + { + "type": "DeclareClass", + "start": 246, + "end": 276, + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 260, + "end": 261, + "loc": { + "start": { + "line": 11, + "column": 14 + }, + "end": { + "line": 11, + "column": 15 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "extends": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 262, + "end": 276, + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 11, + "column": 30 + } + }, + "callProperties": [ + { + "type": "ObjectTypeCallProperty", + "start": 264, + "end": 274, + "loc": { + "start": { + "line": 11, + "column": 18 + }, + "end": { + "line": 11, + "column": 28 + } + }, + "static": false, + "value": { + "type": "FunctionTypeAnnotation", + "start": 264, + "end": 274, + "loc": { + "start": { + "line": 11, + "column": 18 + }, + "end": { + "line": 11, + "column": 28 + } + }, + "params": [], + "rest": null, + "typeParameters": null, + "returnType": { + "type": "NumberTypeAnnotation", + "start": 268, + "end": 274, + "loc": { + "start": { + "line": 11, + "column": 22 + }, + "end": { + "line": 11, + "column": 28 + } + } + } + } + } + ], + "properties": [], + "indexers": [], + "exact": false + } + }, + { + "type": "DeclareClass", + "start": 277, + "end": 314, + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 291, + "end": 292, + "loc": { + "start": { + "line": 12, + "column": 14 + }, + "end": { + "line": 12, + "column": 15 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "extends": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 293, + "end": 314, + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 12, + "column": 37 + } + }, + "callProperties": [ + { + "type": "ObjectTypeCallProperty", + "start": 295, + "end": 312, + "loc": { + "start": { + "line": 12, + "column": 18 + }, + "end": { + "line": 12, + "column": 35 + } + }, + "static": true, + "value": { + "type": "FunctionTypeAnnotation", + "start": 302, + "end": 312, + "loc": { + "start": { + "line": 12, + "column": 25 + }, + "end": { + "line": 12, + "column": 35 + } + }, + "params": [], + "rest": null, + "typeParameters": null, + "returnType": { + "type": "NumberTypeAnnotation", + "start": 306, + "end": 312, + "loc": { + "start": { + "line": 12, + "column": 29 + }, + "end": { + "line": 12, + "column": 35 + } + } + } + } + } + ], + "properties": [], + "indexers": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/flow/type-exports/interface/expected.json b/packages/babylon/test/fixtures/flow/type-exports/interface/expected.json index f835d903ed..1e95a36e2b 100644 --- a/packages/babylon/test/fixtures/flow/type-exports/interface/expected.json +++ b/packages/babylon/test/fixtures/flow/type-exports/interface/expected.json @@ -128,6 +128,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 26, @@ -300,6 +301,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "GenericTypeAnnotation", "start": 65, diff --git a/packages/babylon/test/fixtures/flow/type-parameter-declaration/declare-class-method-reserved-word/expected.json b/packages/babylon/test/fixtures/flow/type-parameter-declaration/declare-class-method-reserved-word/expected.json index c70f16d94e..f238f8f968 100644 --- a/packages/babylon/test/fixtures/flow/type-parameter-declaration/declare-class-method-reserved-word/expected.json +++ b/packages/babylon/test/fixtures/flow/type-parameter-declaration/declare-class-method-reserved-word/expected.json @@ -111,6 +111,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 20, @@ -212,6 +213,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 41, @@ -313,6 +315,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 62, @@ -414,6 +417,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 82, @@ -515,6 +519,7 @@ }, "static": true, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 99, @@ -616,6 +621,7 @@ }, "static": true, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 127, @@ -717,6 +723,7 @@ }, "static": true, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 155, @@ -818,6 +825,7 @@ }, "static": true, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 182, diff --git a/packages/babylon/test/fixtures/flow/type-parameter-declaration/declare-interface-method-reserved-word/expected.json b/packages/babylon/test/fixtures/flow/type-parameter-declaration/declare-interface-method-reserved-word/expected.json index 1bc3f578c1..03814b48e8 100644 --- a/packages/babylon/test/fixtures/flow/type-parameter-declaration/declare-interface-method-reserved-word/expected.json +++ b/packages/babylon/test/fixtures/flow/type-parameter-declaration/declare-interface-method-reserved-word/expected.json @@ -111,6 +111,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 24, @@ -212,6 +213,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 45, @@ -313,6 +315,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 66, @@ -414,6 +417,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 86, diff --git a/packages/babylon/test/fixtures/flow/type-parameter-declaration/interface-reserved-word/expected.json b/packages/babylon/test/fixtures/flow/type-parameter-declaration/interface-reserved-word/expected.json index 42e5d3ce8b..0d65a9a6c5 100644 --- a/packages/babylon/test/fixtures/flow/type-parameter-declaration/interface-reserved-word/expected.json +++ b/packages/babylon/test/fixtures/flow/type-parameter-declaration/interface-reserved-word/expected.json @@ -111,6 +111,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 16, @@ -212,6 +213,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 37, @@ -313,6 +315,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 58, @@ -414,6 +417,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 78, diff --git a/packages/babylon/test/fixtures/flow/type-parameter-declaration/type-object-reserved-word/expected.json b/packages/babylon/test/fixtures/flow/type-parameter-declaration/type-object-reserved-word/expected.json index 5847ba7708..b0f2ed8548 100644 --- a/packages/babylon/test/fixtures/flow/type-parameter-declaration/type-object-reserved-word/expected.json +++ b/packages/babylon/test/fixtures/flow/type-parameter-declaration/type-object-reserved-word/expected.json @@ -109,6 +109,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 13, @@ -210,6 +211,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 34, @@ -311,6 +313,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 55, @@ -412,6 +415,7 @@ }, "static": false, "kind": "init", + "method": true, "value": { "type": "FunctionTypeAnnotation", "start": 75, diff --git a/packages/babylon/test/fixtures/flow/typecasts/2/expected.json b/packages/babylon/test/fixtures/flow/typecasts/2/expected.json index e0f4f47e44..c42819ddfe 100644 --- a/packages/babylon/test/fixtures/flow/typecasts/2/expected.json +++ b/packages/babylon/test/fixtures/flow/typecasts/2/expected.json @@ -246,6 +246,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "NumberTypeAnnotation", "start": 29, @@ -297,6 +298,7 @@ }, "static": false, "kind": "init", + "method": false, "value": { "type": "StringTypeAnnotation", "start": 42, diff --git a/scripts/tests/flow/flow_tests_whitelist.txt b/scripts/tests/flow/flow_tests_whitelist.txt index 3f0abc41bf..2f0ba69391 100644 --- a/scripts/tests/flow/flow_tests_whitelist.txt +++ b/scripts/tests/flow/flow_tests_whitelist.txt @@ -57,3 +57,5 @@ types/parameter_defaults/migrated_0031.js types/parameter_defaults/migrated_0032.js types/string_literal_invalid/migrated_0000.js types/typecasts_invalid/migrated_0001.js +types/import_types/namespace.js +types/import_types/namespace_reserved_value.js