prettier/tests/flow/constructor_annots/__snapshots__/jsfmt.spec.js.snap

76 lines
2.2 KiB
Plaintext

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`constructors.js - flow-verify 1`] = `
// Foo is a class-like function
function Foo() {
this.x = 0; // constructs objects with property x
}
Foo.y = 0; // has static property y
Foo.prototype = { m() { return 0; } };
// exporting Foo directly doesn't work
// Foo's instance and static props are not picked up
exports.Foo = Foo;
// so you want to type Foo, by declaring it as a class
interface IFooPrototype {
m: () => number;
}
interface IFoo extends IFooPrototype {
x: boolean; // error, should have declared x: number instead
static (): void;
constructor(): void;
}
exports.Foo2 = (Foo: Class<IFoo>);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Foo is a class-like function
function Foo() {
this.x = 0; // constructs objects with property x
}
Foo.y = 0; // has static property y
Foo.prototype = {
m() {
return 0;
}
};
// exporting Foo directly doesn't work
// Foo's instance and static props are not picked up
exports.Foo = Foo;
// so you want to type Foo, by declaring it as a class
interface IFooPrototype {
m: () => number;
}
interface IFoo extends IFooPrototype {
x: boolean; // error, should have declared x: number instead
static(): void;
constructor(): void;
}
exports.Foo2 = (Foo: Class<IFoo>);
`;
exports[`test.js - flow-verify 1`] = `
var Foo = require('./constructors').Foo;
var x: string = new Foo().x; // error, found number instead of string
var y: string = Foo.y; // error, found number instead of string
var z: string = new Foo().m();
var Foo2 = require('./constructors').Foo2;
var x2: string = new Foo2().x; // error, found boolean instead of string
var y2: string = Foo2.y; // error, found boolean instead of string
var z2: string = new Foo2().m();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var Foo = require("./constructors").Foo;
var x: string = new Foo().x; // error, found number instead of string
var y: string = Foo.y; // error, found number instead of string
var z: string = new Foo().m();
var Foo2 = require("./constructors").Foo2;
var x2: string = new Foo2().x; // error, found boolean instead of string
var y2: string = Foo2.y; // error, found boolean instead of string
var z2: string = new Foo2().m();
`;