-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
jsfmt.spec.js.snap
73 lines (66 loc) · 2.31 KB
/
jsfmt.spec.js.snap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
exports[`test constructors.js 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;
static y: boolean; // error, should have declared static y: number instead
}
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 {
static (): void,
x: boolean /* error, should have declared x: number instead*/,
static y: boolean /* error, should have declared static y: number instead*/
}
exports.Foo2 = (Foo: Class<IFoo>);
"
`;
exports[`test test.js 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();
"
`;