133 lines
2.4 KiB
Plaintext
133 lines
2.4 KiB
Plaintext
exports[`test id.js 1`] = `
|
|
"declare function id<X>(_: X): X;
|
|
|
|
module.exports = id;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
declare function id<X>(_: X): X;
|
|
|
|
module.exports = id;
|
|
"
|
|
`;
|
|
|
|
exports[`test subtype.js 1`] = `
|
|
"interface Interface {
|
|
m(): void;
|
|
}
|
|
import type { ObjectType } from \'./test\';
|
|
|
|
function subtypeCheck(x: Interface): ObjectType { return x; }
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
interface Interface { m(): void }
|
|
import type { ObjectType } from \"./test\";
|
|
|
|
function subtypeCheck(x: Interface): ObjectType {
|
|
return x;
|
|
}
|
|
"
|
|
`;
|
|
|
|
exports[`test test.js 1`] = `
|
|
"const id = require(\'./id\');
|
|
|
|
export type ObjectType = {
|
|
+m: () => void,
|
|
};
|
|
|
|
function methodCaller(x: ObjectType) {
|
|
x.m();
|
|
};
|
|
|
|
module.exports = id(
|
|
methodCaller
|
|
);
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
const id = require(\"./id\");
|
|
|
|
export type ObjectType = { +m: () => void };
|
|
|
|
function methodCaller(x: ObjectType) {
|
|
x.m();
|
|
}
|
|
|
|
module.exports = id(methodCaller);
|
|
"
|
|
`;
|
|
|
|
exports[`test test2.js 1`] = `
|
|
"/* @flow */
|
|
|
|
function f() {
|
|
return this.p;
|
|
}
|
|
|
|
var a = {
|
|
p: 0,
|
|
f
|
|
}
|
|
|
|
var b = {
|
|
f
|
|
}
|
|
|
|
a.f(); // okey-dokie
|
|
b.f(); // error, property \`p\` not found
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @flow */
|
|
|
|
function f() {
|
|
return this.p;
|
|
}
|
|
|
|
var a = { p: 0, f };
|
|
|
|
var b = { f };
|
|
|
|
a.f();
|
|
// okey-dokie
|
|
b.f(); // error, property \`p\` not found
|
|
"
|
|
`;
|
|
|
|
exports[`test test3.js 1`] = `
|
|
"/* @flow */
|
|
|
|
function foo() {
|
|
this.m();
|
|
}
|
|
|
|
function bar(f: () => void) {
|
|
f(); // passing global object as \`this\`
|
|
({ f }).f(); // passing container object as \`this\`
|
|
}
|
|
|
|
bar(foo); // error, since \`this\` is used non-trivially in \`foo\`
|
|
|
|
function qux(o: { f: () => void }) {
|
|
o.f(); // passing o as \`this\`
|
|
}
|
|
|
|
qux({ f: foo }); // error, since \`this\` is used non-trivially in \`foo\`
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @flow */
|
|
|
|
function foo() {
|
|
this.m();
|
|
}
|
|
|
|
function bar(f: () => void) {
|
|
f();
|
|
// passing global object as \`this\`
|
|
({ f }).f(); // passing container object as \`this\`
|
|
}
|
|
|
|
bar(foo);
|
|
|
|
// error, since \`this\` is used non-trivially in \`foo\`
|
|
function qux(o: { f(): void }) {
|
|
o.f(); // passing o as \`this\`
|
|
}
|
|
|
|
qux({ f: foo }); // error, since \`this\` is used non-trivially in \`foo\`
|
|
"
|
|
`;
|