2017-02-22 00:59:19 +03:00
|
|
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
|
2018-11-25 11:21:14 +03:00
|
|
|
exports[`test.js 1`] = `
|
|
|
|
====================================options=====================================
|
|
|
|
parsers: ["flow"]
|
|
|
|
printWidth: 80
|
|
|
|
| printWidth
|
|
|
|
=====================================input======================================
|
2017-04-12 23:41:51 +03:00
|
|
|
function Foo() { return {}; }
|
2016-12-23 22:31:38 +03:00
|
|
|
var foo: number = new Foo(); // error (returns object literal above)
|
|
|
|
|
|
|
|
function Bar() { return 0; }
|
|
|
|
var bar: number = new Bar(); // error (returns new object)
|
|
|
|
|
|
|
|
function Qux() { }
|
|
|
|
var qux: number = new Qux(); // error (returns new object)
|
|
|
|
|
|
|
|
class A { }
|
|
|
|
function B() { return new A(); }
|
|
|
|
var a: A = new B(); // OK (returns new A)
|
2017-04-08 17:52:38 +03:00
|
|
|
|
|
|
|
// type applications should be applied before deciding if object-like
|
|
|
|
type C<T> = { x: T };
|
|
|
|
function makeC<T>(x: T): C<T> { return {x}; }
|
|
|
|
(new makeC('x'): C<string>); // normally you wouldn't use \`new\`, but you can
|
|
|
|
|
|
|
|
// unions should be split before deciding if object-like
|
|
|
|
function makeUnion(): number | {x: string} {
|
|
|
|
return {x: 'x'};
|
|
|
|
}
|
|
|
|
(new makeUnion(): {x: string}); // error: \`number\` returns {}, missing prop x
|
2018-11-25 11:21:14 +03:00
|
|
|
|
|
|
|
=====================================output=====================================
|
2016-12-23 22:31:38 +03:00
|
|
|
function Foo() {
|
|
|
|
return {};
|
|
|
|
}
|
2017-01-26 22:57:43 +03:00
|
|
|
var foo: number = new Foo(); // error (returns object literal above)
|
2017-01-31 19:27:44 +03:00
|
|
|
|
2016-12-23 22:31:38 +03:00
|
|
|
function Bar() {
|
2016-12-28 05:40:04 +03:00
|
|
|
return 0;
|
2016-12-23 22:31:38 +03:00
|
|
|
}
|
2017-01-26 22:57:43 +03:00
|
|
|
var bar: number = new Bar(); // error (returns new object)
|
2017-01-31 19:27:44 +03:00
|
|
|
|
2017-01-24 20:37:01 +03:00
|
|
|
function Qux() {}
|
2017-01-26 22:57:43 +03:00
|
|
|
var qux: number = new Qux(); // error (returns new object)
|
2017-01-31 19:27:44 +03:00
|
|
|
|
2016-12-23 22:31:38 +03:00
|
|
|
class A {}
|
|
|
|
function B() {
|
2017-01-11 02:51:46 +03:00
|
|
|
return new A();
|
2016-12-23 22:31:38 +03:00
|
|
|
}
|
2017-01-11 18:16:38 +03:00
|
|
|
var a: A = new B(); // OK (returns new A)
|
2017-04-08 17:52:38 +03:00
|
|
|
|
|
|
|
// type applications should be applied before deciding if object-like
|
|
|
|
type C<T> = { x: T };
|
|
|
|
function makeC<T>(x: T): C<T> {
|
|
|
|
return { x };
|
|
|
|
}
|
2017-04-12 23:41:51 +03:00
|
|
|
(new makeC("x"): C<string>); // normally you wouldn't use \`new\`, but you can
|
2017-04-08 17:52:38 +03:00
|
|
|
|
|
|
|
// unions should be split before deciding if object-like
|
|
|
|
function makeUnion(): number | { x: string } {
|
2017-04-12 23:41:51 +03:00
|
|
|
return { x: "x" };
|
2017-04-08 17:52:38 +03:00
|
|
|
}
|
|
|
|
(new makeUnion(): { x: string }); // error: \`number\` returns {}, missing prop x
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2018-11-25 11:21:14 +03:00
|
|
|
================================================================================
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|
|
|
|
|
2018-11-25 11:21:14 +03:00
|
|
|
exports[`test2.js 1`] = `
|
|
|
|
====================================options=====================================
|
|
|
|
parsers: ["flow"]
|
|
|
|
printWidth: 80
|
|
|
|
| printWidth
|
|
|
|
=====================================input======================================
|
2017-04-12 23:41:51 +03:00
|
|
|
declare class D {
|
2016-12-23 22:31:38 +03:00
|
|
|
constructor(): { x: number }; // OK
|
|
|
|
y: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
var d = new D();
|
2017-04-12 23:41:51 +03:00
|
|
|
d.x = ""; // error, string ~/~ number (but property x is found)
|
2016-12-23 22:31:38 +03:00
|
|
|
|
|
|
|
(new D: D); // error, new D is an object, D not in proto chain
|
|
|
|
|
|
|
|
module.exports = D;
|
2018-11-25 11:21:14 +03:00
|
|
|
|
|
|
|
=====================================output=====================================
|
2017-01-10 05:49:06 +03:00
|
|
|
declare class D {
|
2017-09-25 14:45:40 +03:00
|
|
|
constructor(): { x: number }; // OK
|
|
|
|
y: any;
|
2017-01-10 05:49:06 +03:00
|
|
|
}
|
|
|
|
|
2017-01-11 02:51:46 +03:00
|
|
|
var d = new D();
|
2017-04-12 23:41:51 +03:00
|
|
|
d.x = ""; // error, string ~/~ number (but property x is found)
|
2017-01-31 19:27:44 +03:00
|
|
|
|
2017-01-26 22:57:43 +03:00
|
|
|
(new D(): D); // error, new D is an object, D not in proto chain
|
2017-01-31 19:27:44 +03:00
|
|
|
|
2017-01-11 18:16:38 +03:00
|
|
|
module.exports = D;
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2018-11-25 11:21:14 +03:00
|
|
|
================================================================================
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|