- This brings in the flow test suite that contains a ton of JavaScript parsing edge cases - This creates snapshot tests using the pretty printer for all of them - If uncomment `RUN_AST_TESTS` line in `tests/run_specs.js`, it checks ast(pretty_print(x)) == ast(x). Right now, "178 failed, 197 passed, 375 of 377 total". So half of the tests are not passing, most of them are crashes and many of the rest are subtle issues.
36 lines
998 B
JavaScript
36 lines
998 B
JavaScript
/* @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");
|