diff --git a/src/printer.js b/src/printer.js index a86cc6bf..6d48380f 100644 --- a/src/printer.js +++ b/src/printer.js @@ -769,7 +769,7 @@ function genericPrintNoParens(path, options, print) { var args = n.arguments; - if (args && args.length > 0) { + if (args) { parts.push(printArgumentsList(path, options, print)); } diff --git a/tests/annot/__snapshots__/jsfmt.spec.js.snap b/tests/annot/__snapshots__/jsfmt.spec.js.snap index 8dd64d59..5095fdef 100644 --- a/tests/annot/__snapshots__/jsfmt.spec.js.snap +++ b/tests/annot/__snapshots__/jsfmt.spec.js.snap @@ -158,7 +158,7 @@ function foo() { let myClassInstance: MyClass = mk(); // ok (no confusion across scopes) function mk() { - return new MyClass; + return new MyClass(); } class MyClass {} // looked up above diff --git a/tests/arrays/__snapshots__/jsfmt.spec.js.snap b/tests/arrays/__snapshots__/jsfmt.spec.js.snap index 556ad7ba..56b529b4 100644 --- a/tests/arrays/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrays/__snapshots__/jsfmt.spec.js.snap @@ -89,7 +89,7 @@ arr[day] = 0; (arr[day]: string); // error: number ~> string ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var arr = []; -var day = new Date; +var day = new Date(); // Date instances are numeric (see Flow_js.numeric) and thus can index into // arrays. diff --git a/tests/async/__snapshots__/jsfmt.spec.js.snap b/tests/async/__snapshots__/jsfmt.spec.js.snap index 0ad2a98a..564deaeb 100644 --- a/tests/async/__snapshots__/jsfmt.spec.js.snap +++ b/tests/async/__snapshots__/jsfmt.spec.js.snap @@ -182,7 +182,7 @@ class C { var e = async function() {}; var et = async function(a: T) {}; -var n = new async function() {}; +var n = new async function() {}(); var o = { async m() {} }; var ot = { async m(a: T) {} }; @@ -484,7 +484,7 @@ var et = async function(a: T) { var n = new async function() { await 1; -}; +}(); var o = { async m() { diff --git a/tests/binding/__snapshots__/jsfmt.spec.js.snap b/tests/binding/__snapshots__/jsfmt.spec.js.snap index 7bb830c0..bbe81b8a 100644 --- a/tests/binding/__snapshots__/jsfmt.spec.js.snap +++ b/tests/binding/__snapshots__/jsfmt.spec.js.snap @@ -876,11 +876,11 @@ function f5() { // var x: C; // ok -var y = new C; +var y = new C(); // error: let ref before decl from value position class C {} -var z: C = new C; +var z: C = new C(); // ok // --- vars --- // it\'s possible to annotate a var with a non-maybe type, diff --git a/tests/bom/__snapshots__/jsfmt.spec.js.snap b/tests/bom/__snapshots__/jsfmt.spec.js.snap index 3e51773b..7250be84 100644 --- a/tests/bom/__snapshots__/jsfmt.spec.js.snap +++ b/tests/bom/__snapshots__/jsfmt.spec.js.snap @@ -70,7 +70,7 @@ for (let [x, y]: [number, number] of a.entries()) {} // incorrect /* @flow */ // constructor -const a: FormData = new FormData; +const a: FormData = new FormData(); // correct new FormData(\"\"); // incorrect @@ -116,11 +116,11 @@ a.set(\"bar\", new File([], \"q\"), \"x\"); // correct a.set(\"bar\", new File([], \"q\"), 2); // incorrect -a.set(\"bar\", new Blob); +a.set(\"bar\", new Blob()); // correct -a.set(\"bar\", new Blob, \"x\"); +a.set(\"bar\", new Blob(), \"x\"); // correct -a.set(\"bar\", new Blob, 2); +a.set(\"bar\", new Blob(), 2); // incorrect // append a.append(\"foo\", \"bar\"); @@ -139,11 +139,11 @@ a.append(\"bar\", new File([], \"q\"), \"x\"); // correct a.append(\"bar\", new File([], \"q\"), 2); // incorrect -a.append(\"bar\", new Blob); +a.append(\"bar\", new Blob()); // correct -a.append(\"bar\", new Blob, \"x\"); +a.append(\"bar\", new Blob(), \"x\"); // correct -a.append(\"bar\", new Blob, 2); +a.append(\"bar\", new Blob(), 2); // incorrect // delete a.delete(\"xx\"); @@ -218,7 +218,7 @@ new MutationObserver((arr: Array) => true); // correct new MutationObserver(() => {}); // correct -new MutationObserver; +new MutationObserver(); // incorrect new MutationObserver(42); // incorrect diff --git a/tests/bounded_poly/__snapshots__/jsfmt.spec.js.snap b/tests/bounded_poly/__snapshots__/jsfmt.spec.js.snap index 82b019c4..851d2f9e 100644 --- a/tests/bounded_poly/__snapshots__/jsfmt.spec.js.snap +++ b/tests/bounded_poly/__snapshots__/jsfmt.spec.js.snap @@ -67,7 +67,7 @@ function example(o: T): T { var obj1: { x: number, y: string } = example({ x: 0, y: \"\" }); var obj2: { x: number } = example({ x: 0 }); -var c: C = new C; +var c: C = new C(); // error, since T = string is incompatible with number var q: number = c.qux(0); /* 2 more errors, since argument U = number is incompatible with T = string, and diff --git a/tests/builtins/__snapshots__/jsfmt.spec.js.snap b/tests/builtins/__snapshots__/jsfmt.spec.js.snap index 5bd1ee42..c2a155cf 100644 --- a/tests/builtins/__snapshots__/jsfmt.spec.js.snap +++ b/tests/builtins/__snapshots__/jsfmt.spec.js.snap @@ -32,7 +32,7 @@ function f() { } var Foo = require(\"./genericfoo\"); -var foo = new Foo; +var foo = new Foo(); function g() { var foo1 = foo.map(function() { return \"...\"; @@ -60,7 +60,7 @@ class Foo { return this; } map(callbackfn: () => U): Foo { - return new Foo; + return new Foo(); } set(x: T): void {} get(): T { diff --git a/tests/class_statics/__snapshots__/jsfmt.spec.js.snap b/tests/class_statics/__snapshots__/jsfmt.spec.js.snap index bb6b3704..9e4285bd 100644 --- a/tests/class_statics/__snapshots__/jsfmt.spec.js.snap +++ b/tests/class_statics/__snapshots__/jsfmt.spec.js.snap @@ -88,11 +88,11 @@ class B extends A { B.qux(0); // error } static create(): A { - return new this; + return new this(); } static badCreate(): number { - return new this; // error B ~> number + return new this(); // error B ~> number } } @@ -100,7 +100,7 @@ class C { static x: X; static bar(x: X) {} static create(): C<*> { - return new this; + return new this(); } } @@ -113,7 +113,7 @@ class D extends C { } var d: C<*> = D.create(); -(new A: typeof A); +(new A(): typeof A); (B: typeof A); class E { diff --git a/tests/class_subtyping/__snapshots__/jsfmt.spec.js.snap b/tests/class_subtyping/__snapshots__/jsfmt.spec.js.snap index 38c9c03d..0842f2b6 100644 --- a/tests/class_subtyping/__snapshots__/jsfmt.spec.js.snap +++ b/tests/class_subtyping/__snapshots__/jsfmt.spec.js.snap @@ -26,8 +26,8 @@ var I = require(\"./test.js\"); class C extends I.A {} -var x: I.A = new C; -var y: I.B = new C;" +var x: I.A = new C(); +var y: I.B = new C();" `; exports[`test test3.js 1`] = ` @@ -42,7 +42,7 @@ class A {} class B extends A {} class C extends B {} -var c: C> = new C; +var c: C> = new C(); // none of the type args matter var a: A> = c; // the third type arg is incorrect" `; @@ -70,7 +70,7 @@ function foo(c: C, x: X) {} type O = { f: number }; -foo((new C: C), { f_: 0 }); +foo((new C(): C), { f_: 0 }); class D extends C { bar() { @@ -78,5 +78,5 @@ class D extends C { } } -foo(new D, { f_: 0 });" +foo(new D(), { f_: 0 });" `; diff --git a/tests/class_type/__snapshots__/jsfmt.spec.js.snap b/tests/class_type/__snapshots__/jsfmt.spec.js.snap index 43878951..9a2e53fc 100644 --- a/tests/class_type/__snapshots__/jsfmt.spec.js.snap +++ b/tests/class_type/__snapshots__/jsfmt.spec.js.snap @@ -13,14 +13,14 @@ function bar(x: Class): B { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class A {} function foo(x: Class): A { - return new x; // OK + return new x(); // OK } class B { constructor(_: any) {} } function bar(x: Class): B { - return new x; // error (too few args) + return new x(); // error (too few args) }" `; @@ -49,9 +49,9 @@ class A {} class B extends A {} class C {} -check(B, new A); -check(A, new B); -check(C, new A); -check(C, new B); -check(B, new C);" +check(B, new A()); +check(A, new B()); +check(C, new A()); +check(C, new B()); +check(B, new C());" `; diff --git a/tests/classes/__snapshots__/jsfmt.spec.js.snap b/tests/classes/__snapshots__/jsfmt.spec.js.snap index dc2877db..cbf6ec21 100644 --- a/tests/classes/__snapshots__/jsfmt.spec.js.snap +++ b/tests/classes/__snapshots__/jsfmt.spec.js.snap @@ -26,7 +26,7 @@ var A = require(\"./A\"); class B extends A {} -let b = new B; +let b = new B(); (b.foo: number); // error, number !~> function module.exports = B;" @@ -50,7 +50,7 @@ class C extends B { foo(x: string): void {} } -let c = new C; +let c = new C(); (c.foo: number); // error, number !~> function module.exports = C;" @@ -63,7 +63,7 @@ new E().x ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class D {} class E {} -new E.x;" +new E().x;" `; exports[`test class_shapes.js 1`] = ` @@ -120,7 +120,7 @@ class TestClass { c: ?string; } -var x = new TestClass; +var x = new TestClass(); x.a; // ok @@ -144,7 +144,7 @@ class Test2Class extends Test2Superclass { b: number; // conflicts with cast to Foo } -var z = new Test2Class; +var z = new Test2Class(); var w: Foo = z;" `; @@ -183,33 +183,33 @@ var alias2: Alias = _Alias.factory(); // error: bad pun var Bar = class Foo { static factory(): Foo { // OK: Foo is a type in this scope - return new Foo; // OK: Foo is a runtime binding in this scope + return new Foo(); // OK: Foo is a runtime binding in this scope } }; -var bar1: Bar = new Bar; +var bar1: Bar = new Bar(); // OK var bar2: Bar = Bar.factory(); // OK // NB: Don\'t write expected errors using Foo to avoid error collapse hiding an // unexpected failure in the above code. var B = class Baz {}; -var b = new Baz; +var b = new Baz(); // error: Baz is not a runtime binding in this scope var C = class Qux {}; -var c: Qux = new C; +var c: Qux = new C(); // error: Qux is not a type in this scope // OK: anon classes create no binding, but can be bound manually var Anon = class {}; -var anon: Anon = new Anon; +var anon: Anon = new Anon(); class Alias {} var _Alias = class Alias { static factory(): Alias { - return new Alias; + return new Alias(); } }; -var alias1: Alias = new _Alias; +var alias1: Alias = new _Alias(); // error: bad pun var alias2: Alias = _Alias.factory(); // error: bad pun" `; diff --git a/tests/config_munging_underscores/__snapshots__/jsfmt.spec.js.snap b/tests/config_munging_underscores/__snapshots__/jsfmt.spec.js.snap index f757e036..d42ede62 100644 --- a/tests/config_munging_underscores/__snapshots__/jsfmt.spec.js.snap +++ b/tests/config_munging_underscores/__snapshots__/jsfmt.spec.js.snap @@ -85,7 +85,7 @@ class C { _p: string; } -module.exports = new C;" +module.exports = new C();" `; exports[`test commonjs_import.js 1`] = ` diff --git a/tests/constructor_annots/__snapshots__/jsfmt.spec.js.snap b/tests/constructor_annots/__snapshots__/jsfmt.spec.js.snap index 4a656cb6..87424304 100644 --- a/tests/constructor_annots/__snapshots__/jsfmt.spec.js.snap +++ b/tests/constructor_annots/__snapshots__/jsfmt.spec.js.snap @@ -60,16 +60,16 @@ var y2: string = Foo2.y; // error, found boolean instead of string var z2: string = new Foo2().m(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var Foo = require(\"./constructors\").Foo; -var x: string = new Foo.x; +var x: string = new Foo().x; // error, found number instead of string var y: string = Foo.y; // error, found number instead of string -var z: string = new Foo.m(); +var z: string = new Foo().m(); var Foo2 = require(\"./constructors\").Foo2; -var x2: string = new Foo2.x; +var x2: string = new Foo2().x; // error, found boolean instead of string var y2: string = Foo2.y; // error, found boolean instead of string -var z2: string = new Foo2.m();" +var z2: string = new Foo2().m();" `; diff --git a/tests/core_tests/__snapshots__/jsfmt.spec.js.snap b/tests/core_tests/__snapshots__/jsfmt.spec.js.snap index a1e3143e..1d739301 100644 --- a/tests/core_tests/__snapshots__/jsfmt.spec.js.snap +++ b/tests/core_tests/__snapshots__/jsfmt.spec.js.snap @@ -49,7 +49,7 @@ let tests = [ let tests = [ // constructor function() { - new Boolean; + new Boolean(); new Boolean(0); new Boolean(-0); new Boolean(null); @@ -128,11 +128,11 @@ function* generator(): Iterable<[string, number]> { let tests = [ // good constructors function() { - let w = new Map; + let w = new Map(); let x = new Map(null); let y = new Map([ [ \"foo\", 123 ] ]); let z = new Map(generator()); - let a: Map = new Map; + let a: Map = new Map(); let b: Map = new Map([ [ \"foo\", 123 ] ]); let c: Map = new Map(generator()); }, @@ -254,7 +254,7 @@ let ws5 = new WeakSet(numbers()); // error, must be objects ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @flow -let ws = new WeakSet; +let ws = new WeakSet(); let obj: Object = {}; let dict: { foo: string } = { foo: \"bar\" }; diff --git a/tests/covariance/__snapshots__/jsfmt.spec.js.snap b/tests/covariance/__snapshots__/jsfmt.spec.js.snap index f6994bb1..a3cf7b2c 100644 --- a/tests/covariance/__snapshots__/jsfmt.spec.js.snap +++ b/tests/covariance/__snapshots__/jsfmt.spec.js.snap @@ -61,7 +61,7 @@ class NVerbose { } } -var nv: NVerbose = new NVerbose; +var nv: NVerbose = new NVerbose(); nv.x = [ 0 ]; (nv.x[0]: string); // error diff --git a/tests/date/__snapshots__/jsfmt.spec.js.snap b/tests/date/__snapshots__/jsfmt.spec.js.snap index 8dd5a0f3..5960075e 100644 --- a/tests/date/__snapshots__/jsfmt.spec.js.snap +++ b/tests/date/__snapshots__/jsfmt.spec.js.snap @@ -34,7 +34,7 @@ var x: string = d.getTime(); var y: number = d; // valid constructors -new Date; +new Date(); new Date(1234567890); new Date(\"2015/06/18\"); new Date(2015, 6); diff --git a/tests/declaration_files_incremental_haste/__snapshots__/jsfmt.spec.js.snap b/tests/declaration_files_incremental_haste/__snapshots__/jsfmt.spec.js.snap index d4857862..3e4f0f33 100644 --- a/tests/declaration_files_incremental_haste/__snapshots__/jsfmt.spec.js.snap +++ b/tests/declaration_files_incremental_haste/__snapshots__/jsfmt.spec.js.snap @@ -6,7 +6,7 @@ export function foo(): Implementation { return new Implementation; } /* @providesModule A */ class Implementation {} export function foo(): Implementation { - return new Implementation; + return new Implementation(); }" `; @@ -25,7 +25,7 @@ module.exports.fun = (): Implementation => new Implementation; */ class Implementation {} -module.exports.fun = (): Implementation => new Implementation;" +module.exports.fun = (): Implementation => new Implementation();" `; exports[`test ExplicitProvidesModuleSameName.js 1`] = ` @@ -43,7 +43,7 @@ module.exports.fun = (): Implementation => new Implementation; */ class Implementation {} -module.exports.fun = (): Implementation => new Implementation;" +module.exports.fun = (): Implementation => new Implementation();" `; exports[`test ImplicitProvidesModule.js 1`] = ` @@ -61,7 +61,7 @@ module.exports.fun = (): Implementation => new Implementation; */ class Implementation {} -module.exports.fun = (): Implementation => new Implementation;" +module.exports.fun = (): Implementation => new Implementation();" `; exports[`test md5.js 1`] = ` diff --git a/tests/declaration_files_incremental_haste/external/_d3/__snapshots__/jsfmt.spec.js.snap b/tests/declaration_files_incremental_haste/external/_d3/__snapshots__/jsfmt.spec.js.snap index 3385c24d..ce8fdd85 100644 --- a/tests/declaration_files_incremental_haste/external/_d3/__snapshots__/jsfmt.spec.js.snap +++ b/tests/declaration_files_incremental_haste/external/_d3/__snapshots__/jsfmt.spec.js.snap @@ -3,5 +3,5 @@ exports[`test min.js 1`] = ` module.exports.fun = (): Implementation => new Implementation; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Implementation {} -module.exports.fun = (): Implementation => new Implementation;" +module.exports.fun = (): Implementation => new Implementation();" `; diff --git a/tests/declaration_files_incremental_node/__snapshots__/jsfmt.spec.js.snap b/tests/declaration_files_incremental_node/__snapshots__/jsfmt.spec.js.snap index 88c50d5f..f3cbb366 100644 --- a/tests/declaration_files_incremental_node/__snapshots__/jsfmt.spec.js.snap +++ b/tests/declaration_files_incremental_node/__snapshots__/jsfmt.spec.js.snap @@ -4,7 +4,7 @@ export function foo(): Implementation { return new Implementation; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Implementation {} export function foo(): Implementation { - return new Implementation; + return new Implementation(); }" `; diff --git a/tests/declare_export/__snapshots__/jsfmt.spec.js.snap b/tests/declare_export/__snapshots__/jsfmt.spec.js.snap index d3b54776..67666fab 100644 --- a/tests/declare_export/__snapshots__/jsfmt.spec.js.snap +++ b/tests/declare_export/__snapshots__/jsfmt.spec.js.snap @@ -908,22 +908,22 @@ import {doesntExist2} from \"CommonJS_Clobbering_Class\"; import {staticNumber1, baseProp, childProp} from \"CommonJS_Clobbering_Class\"; // Error import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\"; -new CJS_Clobb_Class; -new CJS_Clobb_Class.doesntExist; +new CJS_Clobb_Class(); +new CJS_Clobb_Class().doesntExist; // Error: Class has no \`doesntExist\` property var h1: number = CJS_Clobb_Class.staticNumber2(); var h2: string = CJS_Clobb_Class.staticNumber2(); // Error: number ~> string -var h3: number = new CJS_Clobb_Class.instNumber1(); -var h4: string = new CJS_Clobb_Class.instNumber1(); +var h3: number = new CJS_Clobb_Class().instNumber1(); +var h4: string = new CJS_Clobb_Class().instNumber1(); // Error: number ~> string import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\"; -new CJS_Clobb_Class_NS; +new CJS_Clobb_Class_NS(); // Error: Namespace object isn\'t constructable var i1: number = CJS_Clobb_Class_NS.staticNumber3(); // Error: Class statics not copied to Namespace object -var i2: number = new CJS_Clobb_Class_NS.default.instNumber2(); -var i3: string = new CJS_Clobb_Class_NS.default.instNumber2(); +var i2: number = new CJS_Clobb_Class_NS.default().instNumber2(); +var i3: string = new CJS_Clobb_Class_NS.default().instNumber2(); // Error: number ~> string // =================================== // // == CommonJS Named Exports -> ES6 == // @@ -964,8 +964,8 @@ var o1: number = ES6_Def_NamedFunc1(); var o2: string = ES6_Def_NamedFunc1(); // Error: number ~> string import ES6_Def_NamedClass1 from \"ES6_Default_NamedClass1\"; -var q1: number = new ES6_Def_NamedClass1.givesANum(); -var q2: string = new ES6_Def_NamedClass1.givesANum(); +var q1: number = new ES6_Def_NamedClass1().givesANum(); +var q2: string = new ES6_Def_NamedClass1().givesANum(); // Error: number ~> string //////////////////////////// // == ES6 Named -> ES6 == // @@ -996,8 +996,8 @@ var v1: number = givesANumber(); var v2: string = givesANumber(); // Error: number ~> string import {NumberGenerator} from \"ES6_Named1\"; -var w1: number = new NumberGenerator.givesANumber(); -var w2: string = new NumberGenerator.givesANumber(); +var w1: number = new NumberGenerator().givesANumber(); +var w2: string = new NumberGenerator().givesANumber(); // Error: number ~> string import {varDeclNumber1, varDeclNumber2} from \"ES6_Named1\"; var x1: number = varDeclNumber1; @@ -1032,8 +1032,8 @@ var ae1: number = ES6_Def_NamedFunc2(); var ae2: string = ES6_Def_NamedFunc2(); // Error: number ~> string var ES6_Def_NamedClass2 = require(\"ES6_Default_NamedClass2\").default; -var ag1: number = new ES6_Def_NamedClass2.givesANum(); -var ag2: string = new ES6_Def_NamedClass2.givesANum(); +var ag1: number = new ES6_Def_NamedClass2().givesANum(); +var ag2: string = new ES6_Def_NamedClass2().givesANum(); // Error: number ~> string ///////////////////////////////// // == ES6 Named -> CommonJS == // @@ -1059,8 +1059,8 @@ var ak1: number = givesANumber2(); var ak2: string = givesANumber2(); // Error: number ~> string var NumberGenerator2 = require(\"ES6_Named2\").NumberGenerator2; -var al1: number = new NumberGenerator2.givesANumber(); -var al2: string = new NumberGenerator2.givesANumber(); +var al1: number = new NumberGenerator2().givesANumber(); +var al2: string = new NumberGenerator2().givesANumber(); // Error: number ~> string var varDeclNumber3 = require(\"ES6_Named2\").varDeclNumber3; var varDeclNumber4 = require(\"ES6_Named2\").varDeclNumber4; diff --git a/tests/destructuring/__snapshots__/jsfmt.spec.js.snap b/tests/destructuring/__snapshots__/jsfmt.spec.js.snap index 8eb7086c..90fef426 100644 --- a/tests/destructuring/__snapshots__/jsfmt.spec.js.snap +++ b/tests/destructuring/__snapshots__/jsfmt.spec.js.snap @@ -372,7 +372,7 @@ class Child extends Base { childprop2: number; } -var { baseprop1, childprop1, ...others } = new Child; +var { baseprop1, childprop1, ...others } = new Child(); var bp1: number = baseprop1; var bp1_err: string = baseprop1; diff --git a/tests/dictionary/__snapshots__/jsfmt.spec.js.snap b/tests/dictionary/__snapshots__/jsfmt.spec.js.snap index a800c1ab..97766912 100644 --- a/tests/dictionary/__snapshots__/jsfmt.spec.js.snap +++ b/tests/dictionary/__snapshots__/jsfmt.spec.js.snap @@ -411,11 +411,11 @@ function unsound_dict_has_every_key(o: { [k: string]: X }) { // As with any object type, we can assign subtypes to properties. function set_prop_covariant(o: { [k: string]: B }) { - o.p = new A; + o.p = new A(); // error, A ~> B - o.p = new B; + o.p = new B(); // ok - o.p = new C; // ok + o.p = new C(); // ok } // This isn\'t specific behavior to dictionaries, but for completeness... @@ -472,7 +472,7 @@ function unsound_string_conversion_alias_declared_prop( function unification_dict_values_invariant(x: Array<{ [k: string]: B }>) { let a: Array<{ [k: string]: A }> = x; // error - a[0].p = new A; + a[0].p = new A(); // in[0].p no longer B let b: Array<{ [k: string]: B }> = x; // ok @@ -484,7 +484,7 @@ function unification_dict_values_invariant(x: Array<{ [k: string]: B }>) { function subtype_dict_values_invariant(x: { [k: string]: B }) { let a: { [k: string]: A } = x; // error - a.p = new A; + a.p = new A(); // x[0].p no longer B let b: { [k: string]: B } = x; // ok @@ -495,30 +495,30 @@ function subtype_dict_values_invariant(x: { [k: string]: B }) { function subtype_dict_values_fresh_exception() { let a: { [k: string]: A } = { - a: new A, + a: new A(), // ok, A == A - b: new B, + b: new B(), // ok, B <: A // ok, C <: A - c: new C + c: new C() }; let b: { [k: string]: B } = { - a: new A, + a: new A(), // error, A not <: B - b: new B, + b: new B(), // ok, B == B // ok, C <: A - c: new C + c: new C() }; let c: { [k: string]: C } = { - a: new A, + a: new A(), // error, A not <: C - b: new B, + b: new B(), // error, A not <: C // ok, C == C - c: new C + c: new C() }; } @@ -548,7 +548,7 @@ function unification_mix_with_declared_props_invariant_l( ) { let a: Array<{ [k: string]: B, p: A }> = x; // error: A ~> B - a[0].p = new A; + a[0].p = new A(); // x[0].p no longer B let b: Array<{ [k: string]: B, p: B }> = x; // ok @@ -564,7 +564,7 @@ function unification_mix_with_declared_props_invariant_r( ) { let a: Array<{ [k: string]: A }> = xa; // error - a[0].p = new A; + a[0].p = new A(); // xa[0].p no longer B let b: Array<{ [k: string]: B }> = xb; // ok @@ -576,7 +576,7 @@ function unification_mix_with_declared_props_invariant_r( function subtype_mix_with_declared_props_invariant_l(x: { [k: string]: B }) { let a: { [k: string]: B, p: A } = x; // error: A ~> B - a.p = new A; + a.p = new A(); // x.p no longer B let b: { [k: string]: B, p: B } = x; // ok @@ -592,7 +592,7 @@ function subtype_mix_with_declared_props_invariant_r( ) { let a: { [k: string]: A } = xa; // error - a.p = new A; + a.p = new A(); // xa.p no longer B let b: { [k: string]: B } = xb; // ok @@ -616,7 +616,7 @@ function unification_obj_to_dict( function subtype_dict_to_obj(x: { [k: string]: B }) { let a: { p: A } = x; // error - a.p = new A; + a.p = new A(); // x.p no longer B let b: { p: B } = x; // ok @@ -628,7 +628,7 @@ function subtype_dict_to_obj(x: { [k: string]: B }) { function subtype_obj_to_dict(x: { p: B }) { let a: { [k: string]: A } = x; // error - a.p = new A; + a.p = new A(); // x.p no longer B let b: { [k: string]: B } = x; diff --git a/tests/dom/__snapshots__/jsfmt.spec.js.snap b/tests/dom/__snapshots__/jsfmt.spec.js.snap index 9526397a..1da6f769 100644 --- a/tests/dom/__snapshots__/jsfmt.spec.js.snap +++ b/tests/dom/__snapshots__/jsfmt.spec.js.snap @@ -297,14 +297,14 @@ let listener: EventListener = function(event: Event): void {}; let tests = [ // attachEvent function() { - let target = new EventTarget; + let target = new EventTarget(); (target.attachEvent(\"foo\", listener): void); // invalid, may be undefined (target.attachEvent && target.attachEvent(\"foo\", listener): void); // valid }, // detachEvent function() { - let target = new EventTarget; + let target = new EventTarget(); (target.detachEvent(\"foo\", listener): void); // invalid, may be undefined (target.detachEvent && target.detachEvent(\"foo\", listener): void); // valid @@ -335,7 +335,7 @@ let tests = [ let tests = [ // arcTo function() { - let path = new Path2D; + let path = new Path2D(); (path.arcTo(0, 0, 0, 0, 10): void); // valid (path.arcTo(0, 0, 0, 0, 10, 20, 5): void); diff --git a/tests/duplicate_methods/__snapshots__/jsfmt.spec.js.snap b/tests/duplicate_methods/__snapshots__/jsfmt.spec.js.snap index 81e14103..66511d1d 100644 --- a/tests/duplicate_methods/__snapshots__/jsfmt.spec.js.snap +++ b/tests/duplicate_methods/__snapshots__/jsfmt.spec.js.snap @@ -40,7 +40,7 @@ class C1 { m() {} } -new C1.m(); +new C1().m(); class C2 { get m() { @@ -49,14 +49,14 @@ class C2 { m() {} } -new C2.m(); +new C2().m(); class C3 { set m(x) {} m() {} } -new C3.m(); +new C3().m(); class C4 { get m() { @@ -65,7 +65,7 @@ class C4 { set m(x: number) {} } -new C4.m = new C4.m - 42; +new C4().m = new C4().m - 42; class C5 { m() {} @@ -75,5 +75,5 @@ class C5 { set m(x: number) {} } -new C5.m = new C5.m - 42;" +new C5().m = new C5().m - 42;" `; diff --git a/tests/encaps/__snapshots__/jsfmt.spec.js.snap b/tests/encaps/__snapshots__/jsfmt.spec.js.snap index 526e1305..459e71ef 100644 --- a/tests/encaps/__snapshots__/jsfmt.spec.js.snap +++ b/tests/encaps/__snapshots__/jsfmt.spec.js.snap @@ -17,7 +17,7 @@ var s3 = tag2 \`la la la\`; (s3.foo: number); // error: string ~> number ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class A {} -var a = new A; +var a = new A(); var s1 = \`l\${a.x}r\`; // error: no prop x in A function tag(strings, ...values) { diff --git a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap index 1a040a9c..1a1634e9 100644 --- a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap +++ b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap @@ -245,7 +245,7 @@ export default class Foo { // Regression test for https://github.com/facebook/flow/issues/511 // // Default-exported class should also be available in local scope -new Foo;" +new Foo();" `; exports[`test ES6_Default_NamedClass2.js 1`] = ` @@ -1011,22 +1011,22 @@ import {doesntExist2} from \"CommonJS_Clobbering_Class\"; import {staticNumber1, baseProp, childProp} from \"CommonJS_Clobbering_Class\"; // Error import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\"; -new CJS_Clobb_Class; -new CJS_Clobb_Class.doesntExist; +new CJS_Clobb_Class(); +new CJS_Clobb_Class().doesntExist; // Error: Class has no \`doesntExist\` property var h1: number = CJS_Clobb_Class.staticNumber2(); var h2: string = CJS_Clobb_Class.staticNumber2(); // Error: number ~> string -var h3: number = new CJS_Clobb_Class.instNumber1(); -var h4: string = new CJS_Clobb_Class.instNumber1(); +var h3: number = new CJS_Clobb_Class().instNumber1(); +var h4: string = new CJS_Clobb_Class().instNumber1(); // Error: number ~> string import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\"; -new CJS_Clobb_Class_NS; +new CJS_Clobb_Class_NS(); // Error: Namespace object isn\'t constructable var i1: number = CJS_Clobb_Class_NS.staticNumber3(); // Error: Class statics not copied to Namespace object -var i2: number = new CJS_Clobb_Class_NS.default.instNumber2(); -var i3: string = new CJS_Clobb_Class_NS.default.instNumber2(); +var i2: number = new CJS_Clobb_Class_NS.default().instNumber2(); +var i3: string = new CJS_Clobb_Class_NS.default().instNumber2(); // Error: number ~> string // =================================== // // == CommonJS Named Exports -> ES6 == // @@ -1067,12 +1067,12 @@ var o1: number = ES6_Def_NamedFunc1(); var o2: string = ES6_Def_NamedFunc1(); // Error: number ~> string import ES6_Def_AnonClass1 from \"ES6_Default_AnonClass1\"; -var p1: number = new ES6_Def_AnonClass1.givesANum(); -var p2: string = new ES6_Def_AnonClass1.givesANum(); +var p1: number = new ES6_Def_AnonClass1().givesANum(); +var p2: string = new ES6_Def_AnonClass1().givesANum(); // Error: number ~> string import ES6_Def_NamedClass1 from \"ES6_Default_NamedClass1\"; -var q1: number = new ES6_Def_NamedClass1.givesANum(); -var q2: string = new ES6_Def_NamedClass1.givesANum(); +var q1: number = new ES6_Def_NamedClass1().givesANum(); +var q2: string = new ES6_Def_NamedClass1().givesANum(); // Error: number ~> string //////////////////////////// // == ES6 Named -> ES6 == // @@ -1103,8 +1103,8 @@ var v1: number = givesANumber(); var v2: string = givesANumber(); // Error: number ~> string import {NumberGenerator} from \"ES6_Named1\"; -var w1: number = new NumberGenerator.givesANumber(); -var w2: string = new NumberGenerator.givesANumber(); +var w1: number = new NumberGenerator().givesANumber(); +var w2: string = new NumberGenerator().givesANumber(); // Error: number ~> string import {varDeclNumber1, varDeclNumber2} from \"ES6_Named1\"; var x1: number = varDeclNumber1; @@ -1147,12 +1147,12 @@ var ae1: number = ES6_Def_NamedFunc2(); var ae2: string = ES6_Def_NamedFunc2(); // Error: number ~> string var ES6_Def_AnonClass2 = require(\"ES6_Default_AnonClass2\").default; -var af1: number = new ES6_Def_AnonClass2.givesANum(); -var af2: string = new ES6_Def_AnonClass2.givesANum(); +var af1: number = new ES6_Def_AnonClass2().givesANum(); +var af2: string = new ES6_Def_AnonClass2().givesANum(); // Error: number ~> string var ES6_Def_NamedClass2 = require(\"ES6_Default_NamedClass2\").default; -var ag1: number = new ES6_Def_NamedClass2.givesANum(); -var ag2: string = new ES6_Def_NamedClass2.givesANum(); +var ag1: number = new ES6_Def_NamedClass2().givesANum(); +var ag2: string = new ES6_Def_NamedClass2().givesANum(); // Error: number ~> string ///////////////////////////////// // == ES6 Named -> CommonJS == // @@ -1178,8 +1178,8 @@ var ak1: number = givesANumber2(); var ak2: string = givesANumber2(); // Error: number ~> string var NumberGenerator2 = require(\"ES6_Named2\").NumberGenerator2; -var al1: number = new NumberGenerator2.givesANumber(); -var al2: string = new NumberGenerator2.givesANumber(); +var al1: number = new NumberGenerator2().givesANumber(); +var al2: string = new NumberGenerator2().givesANumber(); // Error: number ~> string var varDeclNumber3 = require(\"ES6_Named2\").varDeclNumber3; var varDeclNumber4 = require(\"ES6_Named2\").varDeclNumber4; diff --git a/tests/es_declare_module/__snapshots__/jsfmt.spec.js.snap b/tests/es_declare_module/__snapshots__/jsfmt.spec.js.snap index 10d8101f..b8fc7736 100644 --- a/tests/es_declare_module/__snapshots__/jsfmt.spec.js.snap +++ b/tests/es_declare_module/__snapshots__/jsfmt.spec.js.snap @@ -76,10 +76,10 @@ import {num3} from \"ES\"; // Error: number ~> string import {C} from \"ES\"; import type {C as CType} from \"ES\"; -(new C: C); +(new C(): C); (42: C); // Error: number ~> C -(new C: CType); +(new C(): CType); (42: CType); // Error: number ~> CType import {T} from \"ES\"; diff --git a/tests/fetch/__snapshots__/jsfmt.spec.js.snap b/tests/fetch/__snapshots__/jsfmt.spec.js.snap index 8034ad48..f72dcd8d 100644 --- a/tests/fetch/__snapshots__/jsfmt.spec.js.snap +++ b/tests/fetch/__snapshots__/jsfmt.spec.js.snap @@ -88,7 +88,7 @@ const c = new Headers({ \"Content-Type\", \"image/jpeg\" }); // correct const d = new Headers(c); // correct -const e: Headers = new Headers; +const e: Headers = new Headers(); // correct e.append(\"Content-Type\", \"image/jpeg\"); // correct @@ -173,7 +173,7 @@ h.arrayBuffer().then((ab: ArrayBuffer) => ab); // correct h.arrayBuffer().then((ab: Buffer) => ab); // incorrect ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ -const a: Request = new Request; +const a: Request = new Request(); // incorrect const b: Request = new Request(\"http://example.org\"); // correct @@ -276,13 +276,13 @@ h.arrayBuffer().then((ab: ArrayBuffer) => ab); // correct h.arrayBuffer().then((ab: Buffer) => ab); // incorrect ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ -const a: Response = new Response; +const a: Response = new Response(); // correct -const b: Response = new Response(new Blob); +const b: Response = new Response(new Blob()); // correct -const c: Response = new Response(new FormData); +const c: Response = new Response(new FormData()); // correct -const d: Response = new Response(new FormData, { status: 404 }); +const d: Response = new Response(new FormData(), { status: 404 }); // correct const e: Response = new Response(\"responsebody\", { status: \"404\" }); // incorrect @@ -358,7 +358,7 @@ const c = new URLSearchParams({ \"key1\", \"value1\" }); // not correct const d = new URLSearchParams(c); // correct -const e: URLSearchParams = new URLSearchParams; +const e: URLSearchParams = new URLSearchParams(); // correct e.append(\"key1\", \"value1\"); // correct diff --git a/tests/generators/__snapshots__/jsfmt.spec.js.snap b/tests/generators/__snapshots__/jsfmt.spec.js.snap index 43c95d6a..55f74c5e 100644 --- a/tests/generators/__snapshots__/jsfmt.spec.js.snap +++ b/tests/generators/__snapshots__/jsfmt.spec.js.snap @@ -226,7 +226,7 @@ class GeneratorExamples { } } -var examples = new GeneratorExamples; +var examples = new GeneratorExamples(); for (var x of examples.infer_stmt()) { (x: string); @@ -297,7 +297,7 @@ class GeneratorExamples { } } -var examples = new GeneratorExamples; +var examples = new GeneratorExamples(); for (var x of examples.infer_stmt()) { (x: string); diff --git a/tests/generics/__snapshots__/jsfmt.spec.js.snap b/tests/generics/__snapshots__/jsfmt.spec.js.snap index 61fade52..f36dbc1d 100644 --- a/tests/generics/__snapshots__/jsfmt.spec.js.snap +++ b/tests/generics/__snapshots__/jsfmt.spec.js.snap @@ -62,7 +62,7 @@ class D { } } -var d = new D; +var d = new D(); var o = {}; var b = d.m(true, 0, o); var s: string = d.x; @@ -78,7 +78,7 @@ class E extends C { } } -var e = new E; +var e = new E(); // error: too few arguments to inherited constructor var x: string = e.set(0); @@ -91,7 +91,7 @@ class H extends G> { } } -var h1 = new H; +var h1 = new H(); h1.foo([ \"...\" ]); var h2: F>>> = h1; diff --git a/tests/geolocation/__snapshots__/jsfmt.spec.js.snap b/tests/geolocation/__snapshots__/jsfmt.spec.js.snap index f9f1420e..b3381792 100644 --- a/tests/geolocation/__snapshots__/jsfmt.spec.js.snap +++ b/tests/geolocation/__snapshots__/jsfmt.spec.js.snap @@ -22,7 +22,7 @@ geolocation.clearWatch(id); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ -var geolocation = new Geolocation; +var geolocation = new Geolocation(); var id = geolocation.watchPosition( position => { var coords: Coordinates = position.coords; diff --git a/tests/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap b/tests/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap index 80dd57a2..941d350d 100644 --- a/tests/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap +++ b/tests/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap @@ -107,7 +107,7 @@ class Foo { set propOverriddenWithSetter(x: string) {} } -var foo = new Foo; +var foo = new Foo(); // Test getting properties with getters var testGetterNoError1: number = foo.goodGetterNoAnnotation; @@ -234,12 +234,12 @@ var obj = { return 4; }, get exampleOfOrderOfGetterAndSetter(): A { - return new A; + return new A(); }, set exampleOfOrderOfGetterAndSetter(x: B) {}, set exampleOfOrderOfGetterAndSetterReordered(x: B) {}, get exampleOfOrderOfGetterAndSetterReordered(): A { - return new A; + return new A(); } }; @@ -264,7 +264,7 @@ var testSubtypingGetterAndSetter: number = obj.propWithSubtypingGetterAndSetter; // When building this feature, it was tempting to flow the setter into the // getter and then use either the getter or setter as the type of the property. // This example shows the danger of using the getter\'s type -obj.exampleOfOrderOfGetterAndSetter = new C; +obj.exampleOfOrderOfGetterAndSetter = new C(); // Error C ~> B // And this example shows the danger of using the setter\'s type. var testExampleOrOrderOfGetterAndSetterReordered: number = obj.exampleOfOrderOfGetterAndSetterReordered; // Error A ~> B" diff --git a/tests/immutable_methods/__snapshots__/jsfmt.spec.js.snap b/tests/immutable_methods/__snapshots__/jsfmt.spec.js.snap index 9dbbe1d5..c1b296bb 100644 --- a/tests/immutable_methods/__snapshots__/jsfmt.spec.js.snap +++ b/tests/immutable_methods/__snapshots__/jsfmt.spec.js.snap @@ -20,8 +20,8 @@ class B extends A { } } class C extends A {} -var a: A = new B; +var a: A = new B(); a.foo = function(): C { - return new C; + return new C(); };" `; diff --git a/tests/import_type/__snapshots__/jsfmt.spec.js.snap b/tests/import_type/__snapshots__/jsfmt.spec.js.snap index ad22ccda..8b187734 100644 --- a/tests/import_type/__snapshots__/jsfmt.spec.js.snap +++ b/tests/import_type/__snapshots__/jsfmt.spec.js.snap @@ -21,7 +21,7 @@ class ClassFoo3 { return 42; } static givesAFoo3(): ClassFoo3 { - return new ClassFoo3; + return new ClassFoo3(); } } @@ -65,17 +65,17 @@ class ClassFoo4 { class ClassFoo5 {} function givesAFoo4(): ClassFoo4 { - return new ClassFoo4; + return new ClassFoo4(); } function givesAFoo5(): ClassFoo5 { - return new ClassFoo5; + return new ClassFoo5(); } exports.ClassFoo4 = ClassFoo4; exports.ClassFoo5 = ClassFoo5; -exports.foo4Inst = new ClassFoo4; -exports.foo5Inst = new ClassFoo5;" +exports.foo4Inst = new ClassFoo4(); +exports.foo5Inst = new ClassFoo5();" `; exports[`test ExportDefault_Class.js 1`] = ` @@ -101,7 +101,7 @@ class ClassFoo1 { } export default ClassFoo1 -export var foo1Inst = new ClassFoo1;" +export var foo1Inst = new ClassFoo1();" `; exports[`test ExportNamed_Alias.js 1`] = ` @@ -156,7 +156,7 @@ class ClassFoo2 { } export {ClassFoo2} -export var foo2Inst = new ClassFoo2;" +export var foo2Inst = new ClassFoo2();" `; exports[`test ExportsANumber.js 1`] = ` @@ -267,7 +267,7 @@ import {foo1Inst} from \"./ExportDefault_Class\"; var a1: ClassFoo1 = foo1Inst; var a2: number = foo1Inst; // Error: ClassFoo1 ~> number -new ClassFoo1; +new ClassFoo1(); // Error: ClassFoo1 is not a value-identifier /////////////////////////////////////////////// // == Importing Class Type (Named Export) == // @@ -278,15 +278,15 @@ import {foo2Inst} from \"./ExportNamed_Class\"; var b1: ClassFoo2 = foo2Inst; var b2: number = foo2Inst; // Error: ClassFoo2 ~> number -new ClassFoo2; +new ClassFoo2(); // Error: ClassFoo2 is not a value-identifier ///////////////////////////////////////////////////// // == Importing Class Type (CJS Default Export) == // ///////////////////////////////////////////////////// import type ClassFoo3T from \"./ExportCJSDefault_Class\"; import ClassFoo3 from \"./ExportCJSDefault_Class\"; -var c1: ClassFoo3T = new ClassFoo3; -new ClassFoo3T; +var c1: ClassFoo3T = new ClassFoo3(); +new ClassFoo3T(); // Error: ClassFoo3 is not a value-identifier /////////////////////////////////////////////////// // == Importing Class Type (CJS Named Export) == // @@ -297,7 +297,7 @@ import {foo4Inst, foo5Inst} from \"./ExportCJSNamed_Class\"; var d1: ClassFoo4 = foo4Inst; var d2: number = foo4Inst; // Error: ClassFoo4 ~> number -new ClassFoo4; +new ClassFoo4(); // Error: ClassFoo4 is not a value-identifier // TODO: this errors correctly, but the message is just \'can\'t resolve name\' var d3: typeof ClassFoo5 = foo5Inst; diff --git a/tests/import_typeof/__snapshots__/jsfmt.spec.js.snap b/tests/import_typeof/__snapshots__/jsfmt.spec.js.snap index 0f819dbc..a4f83afc 100644 --- a/tests/import_typeof/__snapshots__/jsfmt.spec.js.snap +++ b/tests/import_typeof/__snapshots__/jsfmt.spec.js.snap @@ -21,7 +21,7 @@ class ClassFoo3 { return 42; } static givesAFoo3(): ClassFoo3 { - return new ClassFoo3; + return new ClassFoo3(); } } @@ -292,9 +292,9 @@ import typeof ClassFoo1T from \"./ExportDefault_Class\"; import ClassFoo1 from \"./ExportDefault_Class\"; var a1: ClassFoo1T = ClassFoo1; -var a2: ClassFoo1T = new ClassFoo1; +var a2: ClassFoo1T = new ClassFoo1(); // Error: ClassFoo1 (inst) ~> ClassFoo1 (class) -new ClassFoo1T; +new ClassFoo1T(); // Error: ClassFoo1T is not bound to a value ///////////////////////////////////////////////// // == Importing Class Typeof (Named Export) == // @@ -303,9 +303,9 @@ import typeof {ClassFoo2 as ClassFoo2T} from \"./ExportNamed_Class\"; import {ClassFoo2} from \"./ExportNamed_Class\"; var b1: ClassFoo2T = ClassFoo2; -var b2: ClassFoo2T = new ClassFoo2; +var b2: ClassFoo2T = new ClassFoo2(); // Error: ClassFoo2 (inst) ~> ClassFoo2 (class) -new ClassFoo2T; +new ClassFoo2T(); // Error: ClassFoo2T is not bound to a value /////////////////////////////////////////////////////// // == Importing Class Typeof (CJS Default Export) == // @@ -314,7 +314,7 @@ import typeof ClassFoo3T from \"./ExportCJSDefault_Class\"; import ClassFoo3 from \"./ExportCJSDefault_Class\"; var c1: ClassFoo3T = ClassFoo3; -var c2: ClassFoo3T = new ClassFoo3; +var c2: ClassFoo3T = new ClassFoo3(); // Error: ClassFoo3 (inst) ~> ClassFoo3 (class) ///////////////////////////////////////////////////// // == Importing Class Typeof (CJS Named Export) == // @@ -323,7 +323,7 @@ import typeof {ClassFoo4 as ClassFoo4T} from \"./ExportCJSNamed_Class\"; import {ClassFoo4} from \"./ExportCJSNamed_Class\"; var d1: ClassFoo4T = ClassFoo4; -var d2: ClassFoo4T = new ClassFoo4; +var d2: ClassFoo4T = new ClassFoo4(); // Error: ClassFoo4 (inst) ~> ClassFoo4 (class) ////////////////////////////////////////////// // == Import Typeof Alias (Named Export) == // diff --git a/tests/instanceof/__snapshots__/jsfmt.spec.js.snap b/tests/instanceof/__snapshots__/jsfmt.spec.js.snap index b75a85aa..742ebf3f 100644 --- a/tests/instanceof/__snapshots__/jsfmt.spec.js.snap +++ b/tests/instanceof/__snapshots__/jsfmt.spec.js.snap @@ -99,7 +99,7 @@ class X2 { } function x(b) { - return b ? new X1 : new X2; + return b ? new X1() : new X2(); } function consumer1(b) { @@ -126,7 +126,7 @@ class Y2 { } function y(b) { - return b ? new Y1 : new Y2; + return b ? new Y1() : new Y2(); } function consumer3(b) { @@ -153,7 +153,7 @@ class Z2 { } function z(b) { - return b ? new Z1 : new Z2; + return b ? new Z1() : new Z2(); } function consumer5(b) { diff --git a/tests/interface/__snapshots__/jsfmt.spec.js.snap b/tests/interface/__snapshots__/jsfmt.spec.js.snap index 2e778c66..aa2b5959 100644 --- a/tests/interface/__snapshots__/jsfmt.spec.js.snap +++ b/tests/interface/__snapshots__/jsfmt.spec.js.snap @@ -44,11 +44,11 @@ function testInterfaceName(o: I) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class C { x: number } -var x: string = new C.x; +var x: string = new C().x; interface I { x: number } -var i = new I; +var i = new I(); // error function testInterfaceName(o: I) { (o.name: string); @@ -177,5 +177,5 @@ interface I { foo(x: number): void } // error, property \`foo\` not found function declare class C { bar(i: I): void, bar(f: (x: number) => void): void } -new C.bar((x: string) => {}); // error, number ~/~> string" +new C().bar((x: string) => {}); // error, number ~/~> string" `; diff --git a/tests/iterable/__snapshots__/jsfmt.spec.js.snap b/tests/iterable/__snapshots__/jsfmt.spec.js.snap index 1178ef14..9f92f78b 100644 --- a/tests/iterable/__snapshots__/jsfmt.spec.js.snap +++ b/tests/iterable/__snapshots__/jsfmt.spec.js.snap @@ -93,7 +93,7 @@ function foo(strs: Iterable): void { } } -var m: Map = new Map; +var m: Map = new Map(); foo(m.keys());" `; diff --git a/tests/last_duplicate_property_wins/__snapshots__/jsfmt.spec.js.snap b/tests/last_duplicate_property_wins/__snapshots__/jsfmt.spec.js.snap index 1982e849..6af6c4d8 100644 --- a/tests/last_duplicate_property_wins/__snapshots__/jsfmt.spec.js.snap +++ b/tests/last_duplicate_property_wins/__snapshots__/jsfmt.spec.js.snap @@ -68,13 +68,13 @@ class C { } // check -(new C.foo(): boolean); +(new C().foo(): boolean); // last wins -(new C.x: boolean); +(new C().x: boolean); // last wins -(new C.bar: boolean); +(new C().bar: boolean); // last wins -(new C.qux: boolean); +(new C().qux: boolean); // weird outlier where last doesn\'t win in classes // Objects const o = { diff --git a/tests/lib/__snapshots__/jsfmt.spec.js.snap b/tests/lib/__snapshots__/jsfmt.spec.js.snap index f6d0347b..dd2f03b3 100644 --- a/tests/lib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/lib/__snapshots__/jsfmt.spec.js.snap @@ -13,10 +13,10 @@ if (undefined) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var x: string = NaN; var y: string = Number.MAX_VALUE; -var z: number = new TypeError.name; +var z: number = new TypeError().name; var w: string = parseInt(\"...\"); -var a = new Map; +var a = new Map(); a.delete(\"foobar\"); var b = undefined; diff --git a/tests/method_properties/__snapshots__/jsfmt.spec.js.snap b/tests/method_properties/__snapshots__/jsfmt.spec.js.snap index 28edeb1c..3ed323de 100644 --- a/tests/method_properties/__snapshots__/jsfmt.spec.js.snap +++ b/tests/method_properties/__snapshots__/jsfmt.spec.js.snap @@ -43,11 +43,11 @@ class C { } } C.x; -new C.foo.x; +new C().foo.x; C.bar.x; import {Foo} from \"./exports_optional_prop\"; -const foo = new Foo; +const foo = new Foo(); (foo.bar(): string); // error, could be undefined function f(x) { diff --git a/tests/misc/__snapshots__/jsfmt.spec.js.snap b/tests/misc/__snapshots__/jsfmt.spec.js.snap index 8c5a40ed..46cc3a7e 100644 --- a/tests/misc/__snapshots__/jsfmt.spec.js.snap +++ b/tests/misc/__snapshots__/jsfmt.spec.js.snap @@ -86,7 +86,7 @@ var B = require(\"B\"); var f = require(\"A\").fn; function C() { - var o = new B; + var o = new B(); f(o.b); f(o.s); o.fn(); diff --git a/tests/more_annot/__snapshots__/jsfmt.spec.js.snap b/tests/more_annot/__snapshots__/jsfmt.spec.js.snap index 80f6ba5f..2ab283b2 100644 --- a/tests/more_annot/__snapshots__/jsfmt.spec.js.snap +++ b/tests/more_annot/__snapshots__/jsfmt.spec.js.snap @@ -42,9 +42,9 @@ function Foo() { } Foo.prototype.m = function() {}; -var o1: { x: number, m(): void } = new Foo; +var o1: { x: number, m(): void } = new Foo(); -var o2: Foo = new Foo;" +var o2: Foo = new Foo();" `; exports[`test super.js 1`] = ` @@ -58,5 +58,5 @@ class C { } class D extends C {} -var d: { +m: () => void } = new D;" +var d: { +m: () => void } = new D();" `; diff --git a/tests/more_classes/__snapshots__/jsfmt.spec.js.snap b/tests/more_classes/__snapshots__/jsfmt.spec.js.snap index 3536c1a6..53e445a2 100644 --- a/tests/more_classes/__snapshots__/jsfmt.spec.js.snap +++ b/tests/more_classes/__snapshots__/jsfmt.spec.js.snap @@ -33,7 +33,7 @@ class Bar { } bar(z: string, u: string): string { - new Qux.w = \"?\"; + new Qux().w = \"?\"; return z; } } diff --git a/tests/more_path/__snapshots__/jsfmt.spec.js.snap b/tests/more_path/__snapshots__/jsfmt.spec.js.snap index 30cd4af4..efffb41c 100644 --- a/tests/more_path/__snapshots__/jsfmt.spec.js.snap +++ b/tests/more_path/__snapshots__/jsfmt.spec.js.snap @@ -72,7 +72,7 @@ f(x); class A {} function h() { - return 42 || new A; + return 42 || new A(); } var y = h(); @@ -90,7 +90,7 @@ class C { function foo() { var c = \"...\"; - c = new C; + c = new C(); if (bar()) { c.qux(); } diff --git a/tests/name_prop/__snapshots__/jsfmt.spec.js.snap b/tests/name_prop/__snapshots__/jsfmt.spec.js.snap index d9e14e2f..98fca7d3 100644 --- a/tests/name_prop/__snapshots__/jsfmt.spec.js.snap +++ b/tests/name_prop/__snapshots__/jsfmt.spec.js.snap @@ -17,7 +17,7 @@ var test1 = A.bar; var test2: string = A.name; var test3: number = A.name; // Error string ~> number -var a = new A; +var a = new A(); var test4 = a.constructor.bar; // Error bar doesn\'t exist var test5: string = a.constructor.name; diff --git a/tests/node_tests/stream/__snapshots__/jsfmt.spec.js.snap b/tests/node_tests/stream/__snapshots__/jsfmt.spec.js.snap index ec974995..e3dc0506 100644 --- a/tests/node_tests/stream/__snapshots__/jsfmt.spec.js.snap +++ b/tests/node_tests/stream/__snapshots__/jsfmt.spec.js.snap @@ -61,8 +61,8 @@ class MyWriteStream extends stream.Writable {} class MyDuplex extends stream.Duplex {} class MyTransform extends stream.Duplex {} -new MyReadStream - .pipe(new MyDuplex) - .pipe(new MyTransform) - .pipe(new MyWriteStream);" +new MyReadStream() + .pipe(new MyDuplex()) + .pipe(new MyTransform()) + .pipe(new MyWriteStream());" `; diff --git a/tests/object_api/__snapshots__/jsfmt.spec.js.snap b/tests/object_api/__snapshots__/jsfmt.spec.js.snap index 1c401dc4..aeffb1dd 100644 --- a/tests/object_api/__snapshots__/jsfmt.spec.js.snap +++ b/tests/object_api/__snapshots__/jsfmt.spec.js.snap @@ -96,7 +96,7 @@ class C { (Object.create(C.prototype): C); // OK, \`instanceof C\` would be true -(Object.create(new C): C); +(Object.create(new C()): C); // error, object literals don\'t structurally match instances ({ foo: \"foo\" }: C); @@ -127,7 +127,7 @@ class Bar extends Foo {} let tests = [ function() { - const x = new Bar; + const x = new Bar(); (Object.getPrototypeOf(x): Foo); } ];" @@ -191,14 +191,14 @@ class Foo { foo() {} } // constructor and foo not enumerable -(Object.keys(new Foo): Array<\"error\">); +(Object.keys(new Foo()): Array<\"error\">); // error: prop ~> error class Bar extends Foo { bar_prop: string; bar() {} } // only own enumerable props -(Object.keys(new Bar): Array<\"error\">); // error: bar_prop ~> error" +(Object.keys(new Bar()): Array<\"error\">); // error: bar_prop ~> error" `; exports[`test object_missing.js 1`] = ` @@ -403,8 +403,8 @@ var c = { } }; var d: { [key: string]: string } = { foo: \"bar\" }; -var x = new Date; -var y = new Foo; +var x = new Date(); +var y = new Foo(); // // toString diff --git a/tests/optional/__snapshots__/jsfmt.spec.js.snap b/tests/optional/__snapshots__/jsfmt.spec.js.snap index 4fc0e81a..354b30be 100644 --- a/tests/optional/__snapshots__/jsfmt.spec.js.snap +++ b/tests/optional/__snapshots__/jsfmt.spec.js.snap @@ -273,7 +273,7 @@ var i:I = new I(); var j:I = i.map(id => id); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class I { map(mapper: (value?: V) => M): I } -var i: I = new I; +var i: I = new I(); var j: I = i.map(id => id);" `; diff --git a/tests/overload/__snapshots__/jsfmt.spec.js.snap b/tests/overload/__snapshots__/jsfmt.spec.js.snap index 3a350ea2..5274df88 100644 --- a/tests/overload/__snapshots__/jsfmt.spec.js.snap +++ b/tests/overload/__snapshots__/jsfmt.spec.js.snap @@ -69,7 +69,7 @@ declare class C { bar(x: { a: string }): string } -var a = new C; +var a = new C(); a.foo(0); // ok @@ -113,8 +113,8 @@ exports[`test test.js 1`] = ` } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function foo() { - var output = new FakeUint8Array; - output.set(new FakeUint8Array, 0); // matches one of the overloads of set + var output = new FakeUint8Array(); + output.set(new FakeUint8Array(), 0); // matches one of the overloads of set }" `; @@ -128,7 +128,7 @@ var foo = new Foo; (foo.bar(\'hmmm\'): number); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ declare class Foo { bar(x: \"hmm\"): number, bar(x: string): string } -var foo = new Foo; +var foo = new Foo(); (foo.bar(\"hmm\"): number); // OK (foo.bar(\"hmmm\"): number); // error" diff --git a/tests/plsummit/__snapshots__/jsfmt.spec.js.snap b/tests/plsummit/__snapshots__/jsfmt.spec.js.snap index 826c2973..0d238e61 100644 --- a/tests/plsummit/__snapshots__/jsfmt.spec.js.snap +++ b/tests/plsummit/__snapshots__/jsfmt.spec.js.snap @@ -104,7 +104,7 @@ C.prototype.foo = function() { return this.x; }; -var c = new C; +var c = new C(); var x: string = c.foo(); function foo() { diff --git a/tests/poly/__snapshots__/jsfmt.spec.js.snap b/tests/poly/__snapshots__/jsfmt.spec.js.snap index 851f0580..7e8e283f 100644 --- a/tests/poly/__snapshots__/jsfmt.spec.js.snap +++ b/tests/poly/__snapshots__/jsfmt.spec.js.snap @@ -12,18 +12,18 @@ function bar(): A<*> { // error, * can\'t be {} and {x: string} at the same time } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class A {} -new A; +new A(); // OK, implicitly inferred type args class B extends A {} // OK, same as above function foo(b): A { // ok but unsafe, caller may assume any type arg - return b ? (new A: A) : (new A: A); + return b ? (new A(): A) : (new A(): A); } function bar(): A<*> { // error, * can\'t be {} and {x: string} at the same time - return (new A: A<{}>) || (new A: A<{ x: string }>); + return (new A(): A<{}>) || (new A(): A<{ x: string }>); }" `; @@ -63,13 +63,13 @@ class C { // T is implicitly (bounded by) Middle in constructor call if not provided. // Explicit type arg is required in annotation - here a wildcard captures it. -var a: C<*> = new C; +var a: C<*> = new C(); -a.meth(new Middle); -a.meth(new Child); +a.meth(new Middle()); +a.meth(new Child()); a.meth(42); // Error: number ~> Middle -a.meth(new Base); // Error: Base ~> Middle" +a.meth(new Base()); // Error: Base ~> Middle" `; exports[`test issue-1029.js 1`] = ` diff --git a/tests/poly_class_export/__snapshots__/jsfmt.spec.js.snap b/tests/poly_class_export/__snapshots__/jsfmt.spec.js.snap index 8dae54a1..b906f798 100644 --- a/tests/poly_class_export/__snapshots__/jsfmt.spec.js.snap +++ b/tests/poly_class_export/__snapshots__/jsfmt.spec.js.snap @@ -39,7 +39,7 @@ class B extends A { } } -module.exports = new B;" +module.exports = new B();" `; exports[`test C.js 1`] = ` diff --git a/tests/react/__snapshots__/jsfmt.spec.js.snap b/tests/react/__snapshots__/jsfmt.spec.js.snap index 8f64d0d1..b491f649 100644 --- a/tests/react/__snapshots__/jsfmt.spec.js.snap +++ b/tests/react/__snapshots__/jsfmt.spec.js.snap @@ -110,8 +110,8 @@ var b: number = new react.Component(); // Error: ReactComponent ~> number import react from \"react\"; import {Component} from \"react\"; -var a: Component<*, *, *> = new react.Component; -var b: number = new react.Component; // Error: ReactComponent ~> number" +var a: Component<*, *, *> = new react.Component(); +var b: number = new react.Component(); // Error: ReactComponent ~> number" `; exports[`test jsx_spread.js 1`] = ` diff --git a/tests/rec/__snapshots__/jsfmt.spec.js.snap b/tests/rec/__snapshots__/jsfmt.spec.js.snap index ce37121f..b72efb5a 100644 --- a/tests/rec/__snapshots__/jsfmt.spec.js.snap +++ b/tests/rec/__snapshots__/jsfmt.spec.js.snap @@ -93,7 +93,7 @@ class P { // this is like Promise type Pstar = X | Pstar>; // this is like Promise* -var p: P = new P; +var p: P = new P(); (p.x: string); // error var pstar: Pstar = 0; @@ -105,7 +105,7 @@ pstar = p; // OK (pstar.x: string); // error -pstar = (new P: P>); +pstar = (new P(): P>); // OK (pstar.x: string); // error" `; @@ -156,7 +156,7 @@ function bar() { class A { x: A>; } -var a_ = new A; +var a_ = new A(); function foo0() { a_ = a_.x; // terminate despite expanding types } @@ -172,7 +172,7 @@ function foo1(b: S<*>) { class D {} class B extends D {} class C extends B {} -((new C: C): D); // error: number ~/~ string" +((new C(): C): D); // error: number ~/~ string" `; exports[`test test3.js 1`] = ` diff --git a/tests/recheck/__snapshots__/jsfmt.spec.js.snap b/tests/recheck/__snapshots__/jsfmt.spec.js.snap index 62182935..1bec7bc0 100644 --- a/tests/recheck/__snapshots__/jsfmt.spec.js.snap +++ b/tests/recheck/__snapshots__/jsfmt.spec.js.snap @@ -113,7 +113,7 @@ import { C, D } from \"./b2\"; import {C, D} from \"./b2\"; -(new D: C);" +(new D(): C);" `; exports[`test c1.js 1`] = ` @@ -169,7 +169,7 @@ export var x = new A; export class A {} export class B {} -export var x = new A;" +export var x = new A();" `; exports[`test d2.js 1`] = ` @@ -304,7 +304,7 @@ import { D } from \'./g2\'; import {C} from \"./g1\"; import {D} from \"./g2\"; -(new D: C);" +(new D(): C);" `; exports[`test h1.js 1`] = ` diff --git a/tests/recheck/tmp1d/__snapshots__/jsfmt.spec.js.snap b/tests/recheck/tmp1d/__snapshots__/jsfmt.spec.js.snap index 882bb60a..d54f91b8 100644 --- a/tests/recheck/tmp1d/__snapshots__/jsfmt.spec.js.snap +++ b/tests/recheck/tmp1d/__snapshots__/jsfmt.spec.js.snap @@ -9,5 +9,5 @@ export var x = new B; export class A {} export class B {} -export var x = new B;" +export var x = new B();" `; diff --git a/tests/refinements/__snapshots__/jsfmt.spec.js.snap b/tests/refinements/__snapshots__/jsfmt.spec.js.snap index b30eb89e..7962c57c 100644 --- a/tests/refinements/__snapshots__/jsfmt.spec.js.snap +++ b/tests/refinements/__snapshots__/jsfmt.spec.js.snap @@ -414,7 +414,7 @@ function foo1(x: ?Foo): string { } function foo2(x: ?Class): string { - return x && new x.foo || \"\"; + return x && new x().foo || \"\"; }" `; diff --git a/tests/return_new/__snapshots__/jsfmt.spec.js.snap b/tests/return_new/__snapshots__/jsfmt.spec.js.snap index ff481512..34bdf3e8 100644 --- a/tests/return_new/__snapshots__/jsfmt.spec.js.snap +++ b/tests/return_new/__snapshots__/jsfmt.spec.js.snap @@ -15,21 +15,21 @@ var a: A = new B(); // OK (returns new A) function Foo() { return {}; } -var foo: number = new Foo; +var foo: number = new Foo(); // error (returns object literal above) function Bar() { return 0; } -var bar: number = new Bar; +var bar: number = new Bar(); // error (returns new object) function Qux() {} -var qux: number = new Qux; +var qux: number = new Qux(); // error (returns new object) class A {} function B() { - return new A; + return new A(); } -var a: A = new B; // OK (returns new A)" +var a: A = new B(); // OK (returns new A)" `; exports[`test test2.js 1`] = ` @@ -51,10 +51,10 @@ declare class D { y: any } -var d = new D; +var d = new D(); d.x = \"\"; // error, string ~/~ number (but property x is found) -(new D: D); +(new D(): D); // error, new D is an object, D not in proto chain module.exports = D;" `; diff --git a/tests/sealed/__snapshots__/jsfmt.spec.js.snap b/tests/sealed/__snapshots__/jsfmt.spec.js.snap index 2ab3325f..e82791a9 100644 --- a/tests/sealed/__snapshots__/jsfmt.spec.js.snap +++ b/tests/sealed/__snapshots__/jsfmt.spec.js.snap @@ -41,7 +41,7 @@ var export_o: { x:any; } = o; // awkward type cast module.exports = export_o; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function Foo() {} -var o = new Foo; +var o = new Foo(); var x: number = o.x; Foo.prototype.m = function() { diff --git a/tests/statics/__snapshots__/jsfmt.spec.js.snap b/tests/statics/__snapshots__/jsfmt.spec.js.snap index dd3369db..f566f8e1 100644 --- a/tests/statics/__snapshots__/jsfmt.spec.js.snap +++ b/tests/statics/__snapshots__/jsfmt.spec.js.snap @@ -38,5 +38,5 @@ C.g = function(x) { return x; }; -var x: string = new C.f();" +var x: string = new C().f();" `; diff --git a/tests/structural_subtyping/__snapshots__/jsfmt.spec.js.snap b/tests/structural_subtyping/__snapshots__/jsfmt.spec.js.snap index 9236ea09..217adf85 100644 --- a/tests/structural_subtyping/__snapshots__/jsfmt.spec.js.snap +++ b/tests/structural_subtyping/__snapshots__/jsfmt.spec.js.snap @@ -64,10 +64,10 @@ interface IHasXNumber { x: number } interface IHasYString { y: string } -var testInstance1: IHasXString = new ClassWithXString; -var testInstance2: IHasXNumber = new ClassWithXString; +var testInstance1: IHasXString = new ClassWithXString(); +var testInstance2: IHasXNumber = new ClassWithXString(); // Error wrong type -var testInstance3: IHasYString = new ClassWithXString; // Error missing prop" +var testInstance3: IHasYString = new ClassWithXString(); // Error missing prop" `; exports[`test obj.js 1`] = ` diff --git a/tests/super/__snapshots__/jsfmt.spec.js.snap b/tests/super/__snapshots__/jsfmt.spec.js.snap index 1020f9fc..0b0a5fbe 100644 --- a/tests/super/__snapshots__/jsfmt.spec.js.snap +++ b/tests/super/__snapshots__/jsfmt.spec.js.snap @@ -286,8 +286,8 @@ class L extends L_ { return x; } } -(new L_: L_); -(new L: L); +(new L_(): L_); +(new L(): L); // similarly, the converse is true: if the parent\'s constructor returns an // object, then the child does too. @@ -301,8 +301,8 @@ class M extends M_ { return super(); } } -(new M_: { foo: string }); -(new M: { foo: string }); +(new M_(): { foo: string }); +(new M(): { foo: string }); // however! super() calls the parent constructor with the subclass as its \`this\` // value (essentially \`super.constructor.call(this)\`). @@ -317,8 +317,8 @@ class N extends N_ { return super(); } } -(new N_: N_); -(new N: N);" +(new N_(): N_); +(new N(): N);" `; exports[`test import.js 1`] = ` diff --git a/tests/this/__snapshots__/jsfmt.spec.js.snap b/tests/this/__snapshots__/jsfmt.spec.js.snap index 497c00fe..a2320e3f 100644 --- a/tests/this/__snapshots__/jsfmt.spec.js.snap +++ b/tests/this/__snapshots__/jsfmt.spec.js.snap @@ -71,17 +71,17 @@ F.prototype.m = function() { function foo(p: string) {} -var o1 = new F; +var o1 = new F(); // sets o1.x to 0 o1.x = \"\"; foo(o1.x); // ok by definite assignment -var o2 = new F; +var o2 = new F(); o1.y = 0; o2.y = \"\"; foo(o2.y); // setting o1.y to 0 has no effect on o2.y -var o3 = new F; +var o3 = new F(); o3.m(); // sets o3.y to 0 o3.y = \"\"; @@ -175,14 +175,14 @@ class C { return this; } // return type is C } -var c = new C; +var c = new C(); var f = c.foo(); var i = f(); // OK (i: C); // OK class D extends C {} -var d = new D; +var d = new D(); var g = d.foo(); var j = g(); // OK diff --git a/tests/this_type/__snapshots__/jsfmt.spec.js.snap b/tests/this_type/__snapshots__/jsfmt.spec.js.snap index 29930c69..e1049183 100644 --- a/tests/this_type/__snapshots__/jsfmt.spec.js.snap +++ b/tests/this_type/__snapshots__/jsfmt.spec.js.snap @@ -83,8 +83,8 @@ class C { class D extends C {} -var d = new D; -(d: C).next = new C; +var d = new D(); +(d: C).next = new C(); (d.next: D); // sneaky class A { @@ -114,7 +114,7 @@ class Invariant { class Misc { // Set has invariant X out_set(): Set { - return new Set.add(this); + return new Set().add(this); } in_set(_: Set) {} inout_set: Set; @@ -198,7 +198,7 @@ class ImplicitNumber extends Implicit { arg: number; } -(new ImplicitNumber.val: string); // error: number ~> string" +(new ImplicitNumber().val: string); // error: number ~> string" `; exports[`test import.js 1`] = ` @@ -233,27 +233,27 @@ import {A3} from \"./export\"; class B1 extends A1 { foo(): B1 { - return new B1; + return new B1(); } // error } -(new B1.bar(): B1); +(new B1().bar(): B1); // OK class B3 extends A3 { foo(): B3 { - return new B3; + return new B3(); } // error } -(new B3.bar(): B3<*>); +(new B3().bar(): B3<*>); // OK -(new B3.qux(0): string); +(new B3().qux(0): string); // error -(new B3.bar(): A2<*>); +(new B3().bar(): A2<*>); // OK -((new B3.bar(): B3): A2); +((new B3().bar(): B3): A2); // error -((new B3: A2).qux(0): string); // error" +((new B3(): A2).qux(0): string); // error" `; exports[`test interface.js 1`] = ` @@ -294,8 +294,8 @@ class C { } } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -(new DoublyLinkedList.prev(): DoublyLinkedList); -(new DoublyLinkedList.next(): DoublyLinkedList); +(new DoublyLinkedList().prev(): DoublyLinkedList); +(new DoublyLinkedList().next(): DoublyLinkedList); var MiniImmutable = require(\"mini-immutable\"); class C { @@ -321,7 +321,7 @@ class A { // return of foo is not annotated to get around // substituting this below bar(): this { - return new A.foo(); + return new A().foo(); } // same as returning : A, so error qux(): this { @@ -357,7 +357,7 @@ class A { // describes instances of A or subclasses of A: the // meaning of the \`this\` type is not changed simply by // switching into a static context - return new this; // but in a static context, the value \`this\` is bound to + return new this(); // but in a static context, the value \`this\` is bound to // the class, instead of instances of the class } } @@ -451,7 +451,7 @@ class Base { return this; } qux() { - return new Base; + return new Base(); } bar() { @@ -474,22 +474,22 @@ class Override extends Base { } // OK, too bar() { - return new Override; + return new Override(); } // OK (cf. error below) } class InheritOverride extends Override {} -(new Inherit.foo(): Base); -(new Inherit.foo(): Inherit); +(new Inherit().foo(): Base); +(new Inherit().foo(): Inherit); // error (cf. OK below) -((new Inherit: Base).foo(): Base); -(new Override.foo(): Base); -(new Override.foo(): Override); +((new Inherit(): Base).foo(): Base); +(new Override().foo(): Base); +(new Override().foo(): Override); // OK -((new Override: Base).foo(): Base); +((new Override(): Base).foo(): Base); -(new InheritOverride.bar_caller(): InheritOverride); +(new InheritOverride().bar_caller(): InheritOverride); // error // blame flips below // Examples with \`this\` types (compare with examples above) @@ -498,7 +498,7 @@ class Base2 { return this; } qux(): Base2 { - return new Base2; + return new Base2(); } bar(): this { @@ -524,7 +524,7 @@ class Override2 extends Base2 { } // OK, too bar(): Override2 { - return new Override2; + return new Override2(); } // error (cf. OK above) // see exploit below @@ -536,16 +536,16 @@ class Override2 extends Base2 { class InheritOverride2 extends Override2 {} -(new Inherit2.foo(): Base2); -(new Inherit2.foo(): Inherit2); +(new Inherit2().foo(): Base2); +(new Inherit2().foo(): Inherit2); // OK (cf. error above) -((new Inherit2: Base2).foo(): Base2); -(new Override2.foo(): Base2); -(new Override2.foo(): Override2); +((new Inherit2(): Base2).foo(): Base2); +(new Override2().foo(): Base2); +(new Override2().foo(): Override2); // OK -((new Override2: Base2).foo(): Base2); +((new Override2(): Base2).foo(): Base2); -(new InheritOverride2.bar_caller(): InheritOverride2); +(new InheritOverride2().bar_caller(): InheritOverride2); // exploits error above -(new Override2: Base2).corge(new Base2); // exploits error above" +(new Override2(): Base2).corge(new Base2()); // exploits error above" `; diff --git a/tests/throw/__snapshots__/jsfmt.spec.js.snap b/tests/throw/__snapshots__/jsfmt.spec.js.snap index c03fa49e..f569336a 100644 --- a/tests/throw/__snapshots__/jsfmt.spec.js.snap +++ b/tests/throw/__snapshots__/jsfmt.spec.js.snap @@ -27,12 +27,12 @@ function h(x: number): string { */ function f(): number { - throw new Error; // OK to not return + throw new Error(); // OK to not return } function g(a: ?string) { if (a == null) { - throw new Error; + throw new Error(); } return a * 1; // a is not null } @@ -41,7 +41,7 @@ function h(x: number): string { if (x) { return \"foo\"; } else { - throw new Error; + throw new Error(); } }" `; diff --git a/tests/traits/__snapshots__/jsfmt.spec.js.snap b/tests/traits/__snapshots__/jsfmt.spec.js.snap index 8367f69b..026a3ea7 100644 --- a/tests/traits/__snapshots__/jsfmt.spec.js.snap +++ b/tests/traits/__snapshots__/jsfmt.spec.js.snap @@ -35,11 +35,11 @@ declare class Baz { x: T } -(new Foo.x: number); +(new Foo().x: number); // error: Qux wins -(new Foo.y: string); +(new Foo().y: string); // error: Bar wins -(new Foo.z: number); // error: Qux wins" +(new Foo().z: number); // error: Qux wins" `; exports[`test test2.js 1`] = ` diff --git a/tests/try/__snapshots__/jsfmt.spec.js.snap b/tests/try/__snapshots__/jsfmt.spec.js.snap index b84b6763..bc20e064 100644 --- a/tests/try/__snapshots__/jsfmt.spec.js.snap +++ b/tests/try/__snapshots__/jsfmt.spec.js.snap @@ -329,7 +329,7 @@ function f(b) { try { var x: number; if (b) { - throw new Error; + throw new Error(); } x = 0; } catch (e) {} diff --git a/tests/type-at-pos/__snapshots__/jsfmt.spec.js.snap b/tests/type-at-pos/__snapshots__/jsfmt.spec.js.snap index 65500195..3d705615 100644 --- a/tests/type-at-pos/__snapshots__/jsfmt.spec.js.snap +++ b/tests/type-at-pos/__snapshots__/jsfmt.spec.js.snap @@ -92,22 +92,22 @@ mn; // @flow class C {} -var cn: C = new C; +var cn: C = new C(); cn; function foo() { return C; } var D = foo(); -var dn: D = new C; +var dn: D = new C(); dn; type E = C; -var en: E = new C; +var en: E = new C(); en; type F = C; -var fn: F = new C; +var fn: F = new C(); fn; type O = { x: X }; @@ -115,7 +115,7 @@ var on: O = { x: 0 }; on; type Mono = C; -var mn: Mono = new C; +var mn: Mono = new C(); // error: application of non-poly type mn;" `; diff --git a/tests/type_only_vars/__snapshots__/jsfmt.spec.js.snap b/tests/type_only_vars/__snapshots__/jsfmt.spec.js.snap index 7bbb3d28..50fee24d 100644 --- a/tests/type_only_vars/__snapshots__/jsfmt.spec.js.snap +++ b/tests/type_only_vars/__snapshots__/jsfmt.spec.js.snap @@ -102,9 +102,9 @@ var n = Foo; var o = Baz; // errors from value positions only -var a: Foo = new Foo; -var b: Foo = new A.Foo; -(new A.Bar: Baz);" +var a: Foo = new Foo(); +var b: Foo = new A.Foo(); +(new A.Bar(): Baz);" `; exports[`test import_type.js 1`] = ` @@ -141,8 +141,8 @@ var n = Foo; var o = Baz; // But using it in a type should still work -var a: Foo = new actualA.Foo; -(new actualA.Bar: Baz);" +var a: Foo = new actualA.Foo(); +(new actualA.Bar(): Baz);" `; exports[`test type_alias.js 1`] = ` diff --git a/tests/type_param_defaults/__snapshots__/jsfmt.spec.js.snap b/tests/type_param_defaults/__snapshots__/jsfmt.spec.js.snap index 44022c8e..b8c7f197 100644 --- a/tests/type_param_defaults/__snapshots__/jsfmt.spec.js.snap +++ b/tests/type_param_defaults/__snapshots__/jsfmt.spec.js.snap @@ -78,7 +78,7 @@ class A { class B extends A {} var b_number: B = new B(123); -var b_void: B = new B; +var b_void: B = new B(); var b_default: B<> = new B(\"hello\"); var b_star: B<*> = new B(123); @@ -95,7 +95,7 @@ class C extends A {} var c_number: C = new C(123); // Error number ~> ?string -var c_void: C = new C; +var c_void: C = new C(); var c_default: C<> = new C(\"hello\"); var c_star: C<*> = new C(\"hello\"); @@ -107,7 +107,7 @@ var c_star: C<*> = new C(\"hello\"); // Error string ~> boolean class D extends A {} var d_number: D = new D(123); -var d_void: D = new D; +var d_void: D = new D(); var d_default: D = new D(\"hello\"); var d_too_few_args: D<> = new D(\"hello\"); // Error too few tparams @@ -139,7 +139,7 @@ class I extends A {} var i_number: I = new I(123); // Error number ~> ?string -var i_void: I = new I; +var i_void: I = new I(); var i_default: I<> = new I(\"hello\"); var i_star: I<*> = new I(\"hello\");" `; diff --git a/tests/typeof/__snapshots__/jsfmt.spec.js.snap b/tests/typeof/__snapshots__/jsfmt.spec.js.snap index 3440773f..05585e78 100644 --- a/tests/typeof/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typeof/__snapshots__/jsfmt.spec.js.snap @@ -102,7 +102,7 @@ class MyClass1 { // an object produced by the MyClass1 constructor // function. // -var a: MyClass1 = new MyClass1; +var a: MyClass1 = new MyClass1(); // Following tests are errors which conflate the type // of the class value itself with the type of its @@ -136,7 +136,7 @@ class MyClass2 { // to a variable whose annotated type is the type of // the class value (constructor function) MyClass2 itself. // -var c: typeof MyClass2 = new MyClass2; +var c: typeof MyClass2 = new MyClass2(); ////////////////////////////////////// // == typeof <> == // diff --git a/tests/union/__snapshots__/jsfmt.spec.js.snap b/tests/union/__snapshots__/jsfmt.spec.js.snap index 9f5aba92..159b375a 100644 --- a/tests/union/__snapshots__/jsfmt.spec.js.snap +++ b/tests/union/__snapshots__/jsfmt.spec.js.snap @@ -116,7 +116,7 @@ var foo = new Foo(); var foostr: Foo | string = foo; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var Foo = require(\"./issue-323-lib\"); -var foo = new Foo; +var foo = new Foo(); var foostr: Foo | string = foo;" `; @@ -145,8 +145,8 @@ class Foo {} class Bar {} -var foostr: Foo | string = new Foo; -var barstr: Bar | string = new Bar; +var foostr: Foo | string = new Foo(); +var barstr: Bar | string = new Bar(); foostr = barstr;" `; @@ -177,7 +177,7 @@ class Tag { type Node = Tag_ | string; class Tag_ { constructor() { - var a1: Array = [ new Tag_ ]; + var a1: Array = [ new Tag_() ]; var a2: Array = a1; } }" @@ -402,19 +402,19 @@ class C {} class D {} function CD(b) { var E = b ? C : D; - var c: C = new E; + var c: C = new E(); // error, since E could be D, and D is not a subtype of C function qux(e: E) {} // this annotation is an error: is it C, or is it D? function qux2(e: C | D) {} // OK - qux2(new C); + qux2(new C()); } declare class F { foo(x: number): void, foo(x: string): void } function corge(b) { var x = b ? \"\" : 0; - new F.foo(x); + new F().foo(x); }" `; diff --git a/tests/union_new/__snapshots__/jsfmt.spec.js.snap b/tests/union_new/__snapshots__/jsfmt.spec.js.snap index fec9b8f8..e2ebbb3e 100644 --- a/tests/union_new/__snapshots__/jsfmt.spec.js.snap +++ b/tests/union_new/__snapshots__/jsfmt.spec.js.snap @@ -484,7 +484,7 @@ function inst(a: A5 | A6) {} class B5 {} class B6 {} -inst([ new B6 ]); +inst([ new B6() ]); type A5 = B5[]; type A6 = B6[];" @@ -605,7 +605,7 @@ class C {} function inst(a: C | C) {} -inst((new C: A3)); +inst((new C(): A3)); type A3 = C; @@ -1150,10 +1150,10 @@ class D {} function check_inst(_: C | D) {} // ok -check_inst(new D); +check_inst(new D()); // ...even when they \"flow\" in -check_inst(id(new C)); +check_inst(id(new C())); //////////////////////// // function annotations @@ -1192,7 +1192,7 @@ class P {} function check_poly_inst(_: P | P) {} // help! -check_poly_inst(new P);" +check_poly_inst(new P());" `; exports[`test test11.js 1`] = ` @@ -1445,7 +1445,7 @@ function f() { return 0; } -new C.m(f());" +new C().m(f());" `; exports[`test test19.js 1`] = ` @@ -1467,7 +1467,7 @@ declare class D { // constructor overloads function m() { - return new D; + return new D(); } declare class D { constructor(_: void): void, constructor(_: null): void }" @@ -1758,7 +1758,7 @@ declare class Record { set(x: \"bar\", y: string): void } -new Record.set(\"foo\", \"42\");" +new Record().set(\"foo\", \"42\");" `; exports[`test test27.js 1`] = ` @@ -1957,7 +1957,7 @@ declare class ImmutableMap {} declare function convert(iter: SomeIterable<[K, V]>): ImmutableMap; function foo(): ImmutableMap { - const countersGlobalMap = new SomeMap; + const countersGlobalMap = new SomeMap(); countersGlobalMap.set(\"\", false); return convert(countersGlobalMap); }" diff --git a/tests/while/__snapshots__/jsfmt.spec.js.snap b/tests/while/__snapshots__/jsfmt.spec.js.snap index d07f7c7b..a4acff0c 100644 --- a/tests/while/__snapshots__/jsfmt.spec.js.snap +++ b/tests/while/__snapshots__/jsfmt.spec.js.snap @@ -57,11 +57,11 @@ while (node) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class C { m() { - return new C; + return new C(); } } function blah() {} -var node: ?C = new C; +var node: ?C = new C(); while (node) { var parent = node.m(); var cloneable: C = node;