prettier/tests/sealed/__snapshots__/jsfmt.spec.js.snap

88 lines
1.7 KiB
Plaintext
Raw Normal View History

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();
o.x = "...";
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
function Foo() {
}
var o = new Foo();
var x: number = o.x;
Foo.prototype.m = function() {
return this.x;
};
var y: number = o.m();
o.x = "...";
Foo.prototype = {
m: function() {
return false;
}
};
2016-12-27 21:29:31 +03:00
var export_o: { x: any } = o;
module.exports = export_o;
"
`;
exports[`test sealed.js 1`] = `
"var o = require('./proto');
o.z = 0;
var x:string = o.x;
var Bar = require('./function');
var a = new Bar(234);
a.x = 123;
a.y = 'abc'; // error, needs to be declared in Bar's constructor
(a.getX(): number);
(a.getY(): string);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// error, needs to be declared in Bar's constructor
var o = require("./proto");
o.z = 0;
var x: string = o.x;
var Bar = require("./function");
var a = new Bar(234);
a.x = 123;
a.y = "abc";
(a.getX(): number);
(a.getY(): string);
"
`;