I find it weird to put `{}` together. So I figured I would change it to have an empty line and ask for feedback :)

Beware: most of the test cases are not representative of real code, you almost never define blocks with no content in practice.
174 lines
4.0 KiB
Plaintext
174 lines
4.0 KiB
Plaintext
exports[`test B.js 1`] = `
|
|
"/* @flow */
|
|
|
|
exports.numberValue = 42;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @flow */
|
|
|
|
exports.numberValue = 42;
|
|
"
|
|
`;
|
|
|
|
exports[`test C.js 1`] = `
|
|
"/* @flow */
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
"
|
|
`;
|
|
|
|
exports[`test E.js 1`] = `
|
|
"/* @flow */
|
|
|
|
// Local \`exports\` var is just a ref to module.exports, so mutating the original
|
|
// value will affect the exports object but re-binding it makes it useless and
|
|
// does not affect the exports value.
|
|
module.exports = {
|
|
numberValue: 42
|
|
};
|
|
|
|
exports = {stringValue: \'\'};
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @flow */
|
|
|
|
// Local \`exports\` var is just a ref to module.exports, so mutating the original
|
|
// value will affect the exports object but re-binding it makes it useless and
|
|
// does not affect the exports value.
|
|
module.exports = { numberValue: 42 };
|
|
|
|
exports = { stringValue: \"\" };
|
|
"
|
|
`;
|
|
|
|
exports[`test ProvidesModuleA.js 1`] = `
|
|
"/**
|
|
* @providesModule A
|
|
* @flow
|
|
*/
|
|
|
|
exports.numberValue = 42;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/**
|
|
* @providesModule A
|
|
* @flow
|
|
*/
|
|
|
|
exports.numberValue = 42;
|
|
"
|
|
`;
|
|
|
|
exports[`test ProvidesModuleD.js 1`] = `
|
|
"/**
|
|
* @providesModule D
|
|
* @flow
|
|
*/
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
"
|
|
`;
|
|
|
|
exports[`test not_builtin_require.js 1`] = `
|
|
"// @flow
|
|
|
|
function require() {}
|
|
require(\"not a module name\");
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// @flow
|
|
|
|
function require() {
|
|
}
|
|
require(\"not a module name\");
|
|
"
|
|
`;
|
|
|
|
exports[`test not_builtin_require2.js 1`] = `
|
|
"// @flow
|
|
|
|
type require = number;
|
|
var a: require = 42;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// @flow
|
|
|
|
type require = number;
|
|
var a: require = 42;
|
|
"
|
|
`;
|
|
|
|
exports[`test require.js 1`] = `
|
|
"/* @flow */
|
|
|
|
function takesANumber(num: number): void {}
|
|
function takesAString(str: string): void {}
|
|
|
|
// @providesModule
|
|
var A = require(\"A\");
|
|
takesANumber(A.numberValue);
|
|
takesAString(A.numberValue);
|
|
|
|
// File path
|
|
var B = require(\"./B\");
|
|
takesANumber(B.numberValue);
|
|
takesAString(B.numberValue);
|
|
|
|
// C.js exists, but not as a providesModule
|
|
require(\"C\");
|
|
|
|
// @providesModule D exists, but not as a filename
|
|
require(\"./D\");
|
|
|
|
// E exports an object with a numVal property
|
|
var E = require(\'./E\');
|
|
var e_1: number = E.numberValue;
|
|
E.stringValue; // Error: The E exports obj has no \'stringValue\' property
|
|
|
|
// We require that the param passed to require() be a string literal to support
|
|
// guaranteed static extraction
|
|
var a = \'./E\';
|
|
require(a); // Error: Param must be string literal
|
|
require(\`./E\`); // template literals are ok...
|
|
require(\`\${\'./E\'}\`); // error: but only if they have no expressions
|
|
|
|
// require.call is allowed but circumverts Flow\'s static analysis
|
|
require.call(null, \"DoesNotExist\");
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* @flow */
|
|
|
|
function takesANumber(num: number): void {
|
|
}
|
|
function takesAString(str: string): void {
|
|
}
|
|
|
|
// @providesModule
|
|
var A = require(\"A\");
|
|
takesANumber(A.numberValue);
|
|
takesAString(A.numberValue);
|
|
|
|
// File path
|
|
var B = require(\"./B\");
|
|
takesANumber(B.numberValue);
|
|
takesAString(B.numberValue);
|
|
|
|
// C.js exists, but not as a providesModule
|
|
require(\"C\");
|
|
|
|
// @providesModule D exists, but not as a filename
|
|
require(\"./D\");
|
|
|
|
// E exports an object with a numVal property
|
|
var E = require(\"./E\");
|
|
var e_1: number = E.numberValue;
|
|
E.stringValue;
|
|
// Error: The E exports obj has no \'stringValue\' property
|
|
// We require that the param passed to require() be a string literal to support
|
|
// guaranteed static extraction
|
|
var a = \"./E\";
|
|
require(a);
|
|
// Error: Param must be string literal
|
|
require(\`./E\`);
|
|
// template literals are ok...
|
|
require(\`\${\"./E\"}\`);
|
|
// error: but only if they have no expressions
|
|
// require.call is allowed but circumverts Flow\'s static analysis
|
|
require.call(null, \"DoesNotExist\");
|
|
"
|
|
`;
|