2017-02-22 00:59:19 +03:00
|
|
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
|
2018-11-25 11:21:14 +03:00
|
|
|
exports[`constructors.js 1`] = `
|
|
|
|
====================================options=====================================
|
|
|
|
parsers: ["flow"]
|
|
|
|
printWidth: 80
|
|
|
|
| printWidth
|
|
|
|
=====================================input======================================
|
2017-04-12 23:41:51 +03:00
|
|
|
// Foo is a class-like function
|
2016-12-23 22:31:38 +03:00
|
|
|
function Foo() {
|
|
|
|
this.x = 0; // constructs objects with property x
|
|
|
|
}
|
|
|
|
Foo.y = 0; // has static property y
|
|
|
|
Foo.prototype = { m() { return 0; } };
|
|
|
|
|
2017-02-22 00:59:19 +03:00
|
|
|
// exporting Foo directly doesn't work
|
|
|
|
// Foo's instance and static props are not picked up
|
2016-12-23 22:31:38 +03:00
|
|
|
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;
|
2017-05-20 13:16:28 +03:00
|
|
|
constructor(): void;
|
2016-12-23 22:31:38 +03:00
|
|
|
}
|
|
|
|
exports.Foo2 = (Foo: Class<IFoo>);
|
2018-11-25 11:21:14 +03:00
|
|
|
|
|
|
|
=====================================output=====================================
|
2016-12-27 21:29:31 +03:00
|
|
|
// Foo is a class-like function
|
|
|
|
function Foo() {
|
2017-01-10 05:49:06 +03:00
|
|
|
this.x = 0; // constructs objects with property x
|
2016-12-27 21:29:31 +03:00
|
|
|
}
|
2017-01-26 22:57:43 +03:00
|
|
|
Foo.y = 0; // has static property y
|
2016-12-27 21:29:31 +03:00
|
|
|
Foo.prototype = {
|
|
|
|
m() {
|
2016-12-28 05:40:04 +03:00
|
|
|
return 0;
|
2016-12-27 21:29:31 +03:00
|
|
|
}
|
|
|
|
};
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2017-02-22 00:59:19 +03:00
|
|
|
// exporting Foo directly doesn't work
|
|
|
|
// Foo's instance and static props are not picked up
|
2016-12-27 21:29:31 +03:00
|
|
|
exports.Foo = Foo;
|
2017-01-10 05:49:06 +03:00
|
|
|
|
|
|
|
// so you want to type Foo, by declaring it as a class
|
2017-01-30 20:08:55 +03:00
|
|
|
interface IFooPrototype {
|
2017-09-25 14:45:40 +03:00
|
|
|
m: () => number;
|
2017-01-30 20:08:55 +03:00
|
|
|
}
|
2016-12-31 01:00:11 +03:00
|
|
|
interface IFoo extends IFooPrototype {
|
2017-09-25 14:45:40 +03:00
|
|
|
x: boolean; // error, should have declared x: number instead
|
2018-02-06 20:01:58 +03:00
|
|
|
static(): void;
|
2017-09-25 14:45:40 +03:00
|
|
|
constructor(): void;
|
2016-12-31 01:00:11 +03:00
|
|
|
}
|
2017-01-11 18:16:38 +03:00
|
|
|
exports.Foo2 = (Foo: Class<IFoo>);
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2018-11-25 11:21:14 +03:00
|
|
|
================================================================================
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|
|
|
|
|
2018-11-25 11:21:14 +03:00
|
|
|
exports[`test.js 1`] = `
|
|
|
|
====================================options=====================================
|
|
|
|
parsers: ["flow"]
|
|
|
|
printWidth: 80
|
|
|
|
| printWidth
|
|
|
|
=====================================input======================================
|
2017-04-12 23:41:51 +03:00
|
|
|
var Foo = require('./constructors').Foo;
|
2016-12-23 22:31:38 +03:00
|
|
|
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();
|
|
|
|
|
2017-02-22 00:59:19 +03:00
|
|
|
var Foo2 = require('./constructors').Foo2;
|
2016-12-23 22:31:38 +03:00
|
|
|
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();
|
2018-11-25 11:21:14 +03:00
|
|
|
|
|
|
|
=====================================output=====================================
|
2017-04-12 23:41:51 +03:00
|
|
|
var Foo = require("./constructors").Foo;
|
2017-01-26 22:57:43 +03:00
|
|
|
var x: string = new Foo().x; // error, found number instead of string
|
|
|
|
var y: string = Foo.y; // error, found number instead of string
|
2017-01-11 02:51:46 +03:00
|
|
|
var z: string = new Foo().m();
|
2017-01-10 05:49:06 +03:00
|
|
|
|
2017-04-12 23:41:51 +03:00
|
|
|
var Foo2 = require("./constructors").Foo2;
|
2017-01-26 22:57:43 +03:00
|
|
|
var x2: string = new Foo2().x; // error, found boolean instead of string
|
|
|
|
var y2: string = Foo2.y; // error, found boolean instead of string
|
2017-01-11 18:16:38 +03:00
|
|
|
var z2: string = new Foo2().m();
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2018-11-25 11:21:14 +03:00
|
|
|
================================================================================
|
2016-12-23 22:31:38 +03:00
|
|
|
`;
|