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 */
|
|
|
|
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;
|
|
|
|
"
|
|
|
|
`;
|
|
|
|
|
|
|
|
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 08:01:44 +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-27 21:29:31 +03:00
|
|
|
// awkward type cast
|
2016-12-23 22:31:38 +03:00
|
|
|
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 08:01:44 +03:00
|
|
|
o.x = "...";
|
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
|
|
|
}
|
|
|
|
};
|
2016-12-27 21:29:31 +03:00
|
|
|
var export_o: { x: any } = o;
|
2016-12-23 22:31:38 +03:00
|
|
|
module.exports = export_o;
|
|
|
|
"
|
|
|
|
`;
|
|
|
|
|
|
|
|
exports[`test sealed.js 1`] = `
|
2016-12-30 08:01:44 +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 08:01:44 +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 08:01:44 +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 08:01:44 +03:00
|
|
|
// error, needs to be declared in Bar's constructor
|
|
|
|
var o = require("./proto");
|
2016-12-28 05:40:04 +03:00
|
|
|
o.z = 0;
|
2016-12-23 22:31:38 +03:00
|
|
|
var x: string = o.x;
|
2016-12-30 08:01:44 +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 08:01:44 +03:00
|
|
|
a.y = "abc";
|
2016-12-23 22:31:38 +03:00
|
|
|
(a.getX(): number);
|
|
|
|
(a.getY(): string);
|
|
|
|
"
|
|
|
|
`;
|