2016-12-23 22:31:38 +03:00
|
|
|
exports[`test test.js 1`] = `
|
|
|
|
"function Foo() { return {}; }
|
|
|
|
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)
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
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)
|
|
|
|
"
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`test test2.js 1`] = `
|
|
|
|
"declare class D {
|
|
|
|
constructor(): { x: number }; // OK
|
|
|
|
y: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
var d = new D();
|
2016-12-30 19:56:42 +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;
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2017-01-10 05:49:06 +03:00
|
|
|
declare class D {
|
2017-01-26 22:57:43 +03:00
|
|
|
constructor(): { x: number }, // OK
|
2017-01-10 05:49:06 +03:00
|
|
|
y: any
|
|
|
|
}
|
|
|
|
|
2017-01-11 02:51:46 +03:00
|
|
|
var d = new D();
|
2017-01-26 22:57:43 +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;
|
|
|
|
"
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|