2016-12-23 22:31:38 +03:00
|
|
|
exports[`test function.js 1`] = `
|
|
|
|
"/* @flow */
|
|
|
|
|
|
|
|
function Bar(x: number) {
|
|
|
|
this.x = x;
|
|
|
|
}
|
|
|
|
Bar.prototype.getX = function() { return this.x; }
|
|
|
|
Bar.prototype.getY = function(): string { return this.y; }
|
|
|
|
|
|
|
|
module.exports = Bar;
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
/* @flow */
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2016-12-23 22:31:38 +03:00
|
|
|
function Bar(x: number) {
|
|
|
|
this.x = x;
|
|
|
|
}
|
|
|
|
Bar.prototype.getX = function() {
|
|
|
|
return this.x;
|
|
|
|
};
|
|
|
|
Bar.prototype.getY = function(): string {
|
|
|
|
return this.y;
|
|
|
|
};
|
2017-01-10 05:49:06 +03:00
|
|
|
|
|
|
|
module.exports = Bar;"
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`test proto.js 1`] = `
|
|
|
|
"function Foo() { }
|
|
|
|
var o = new Foo();
|
|
|
|
var x:number = o.x;
|
|
|
|
|
|
|
|
Foo.prototype.m = function() { return this.x; }
|
|
|
|
|
|
|
|
var y:number = o.m();
|
2016-12-30 19:56:42 +03:00
|
|
|
o.x = \"...\";
|
2016-12-23 22:31:38 +03:00
|
|
|
|
|
|
|
Foo.prototype = { m: function() { return false; } }
|
|
|
|
|
|
|
|
var export_o: { x:any; } = o; // awkward type cast
|
|
|
|
|
|
|
|
module.exports = export_o;
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2016-12-31 07:01:07 +03:00
|
|
|
function Foo() {}
|
2016-12-23 22:31:38 +03:00
|
|
|
var o = new Foo();
|
|
|
|
var x: number = o.x;
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2016-12-23 22:31:38 +03:00
|
|
|
Foo.prototype.m = function() {
|
|
|
|
return this.x;
|
|
|
|
};
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2016-12-23 22:31:38 +03:00
|
|
|
var y: number = o.m();
|
2016-12-30 19:56:42 +03:00
|
|
|
o.x = \"...\";
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2016-12-23 22:31:38 +03:00
|
|
|
Foo.prototype = {
|
|
|
|
m: function() {
|
2016-12-28 05:40:04 +03:00
|
|
|
return false;
|
2016-12-23 22:31:38 +03:00
|
|
|
}
|
|
|
|
};
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2016-12-27 21:29:31 +03:00
|
|
|
var export_o: { x: any } = o;
|
2017-01-10 05:49:06 +03:00
|
|
|
// awkward type cast
|
|
|
|
module.exports = export_o;"
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`test sealed.js 1`] = `
|
2016-12-30 19:56:42 +03:00
|
|
|
"var o = require(\'./proto\');
|
2016-12-23 22:31:38 +03:00
|
|
|
|
|
|
|
o.z = 0;
|
|
|
|
var x:string = o.x;
|
|
|
|
|
2016-12-30 19:56:42 +03:00
|
|
|
var Bar = require(\'./function\');
|
2016-12-23 22:31:38 +03:00
|
|
|
var a = new Bar(234);
|
|
|
|
a.x = 123;
|
2016-12-30 19:56:42 +03:00
|
|
|
a.y = \'abc\'; // error, needs to be declared in Bar\'s constructor
|
2016-12-23 22:31:38 +03:00
|
|
|
(a.getX(): number);
|
|
|
|
(a.getY(): string);
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2016-12-30 19:56:42 +03:00
|
|
|
var o = require(\"./proto\");
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2016-12-28 05:40:04 +03:00
|
|
|
o.z = 0;
|
2016-12-23 22:31:38 +03:00
|
|
|
var x: string = o.x;
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2016-12-30 19:56:42 +03:00
|
|
|
var Bar = require(\"./function\");
|
2016-12-28 05:40:04 +03:00
|
|
|
var a = new Bar(234);
|
|
|
|
a.x = 123;
|
2016-12-30 19:56:42 +03:00
|
|
|
a.y = \"abc\";
|
2017-01-10 05:49:06 +03:00
|
|
|
// error, needs to be declared in Bar\'s constructor
|
2016-12-23 22:31:38 +03:00
|
|
|
(a.getX(): number);
|
2017-01-10 05:49:06 +03:00
|
|
|
(a.getY(): string);"
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|