Files
test-repo/tests/const_params/__snapshots__/jsfmt.spec.js.snap
T

65 lines
1.4 KiB
Plaintext

exports[`test test.js 1`] = `
"/**
* test handling of const params
* - reassignment prohibited
* - durable refinements
*
* Currently gated in .flowconfig:
*
* [options]
* experimental.const_params
*
* Syntax to follow
*
* @flow
*/
function cannot_reassign(x: string) {
x = \"hey\"; // error, const param cannot be reassigned
}
// Note: const params use the same machinery as explicit
// const bindings, which are tested more extensively elsewhere.
// Here we\'re just making sure the machinery is hooked up.
//
function durable_refi(x: ?number) {
if (x) {
// ok: if x is truthy here, it\'s truthy everywhere
return () => { var y:number = x; };
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
* test handling of const params
* - reassignment prohibited
* - durable refinements
*
* Currently gated in .flowconfig:
*
* [options]
* experimental.const_params
*
* Syntax to follow
*
* @flow
*/
// error, const param cannot be reassigned
// Note: const params use the same machinery as explicit
// const bindings, which are tested more extensively elsewhere.
// Here we\'re just making sure the machinery is hooked up.
//
// ok: if x is truthy here, it\'s truthy everywhere
function cannot_reassign(x: string) {
x = \"hey\";
}
function durable_refi(x: ?number) {
if (x) {
return () => {
var y: number = x;
};
}
}
"
`;