* new_tests * move_all_clobbered_tests * remove all the tests that no longer exist * re-run flow tests * Move all the flow tests to tests/flow and prettier to tests/ * Move prettier tests to their own folders * Add jsfmt files * run prettier snapshot tests
38 lines
666 B
JavaScript
38 lines
666 B
JavaScript
/* @flow */
|
|
|
|
function veryOptimistic(isThisAwesome: true): boolean {
|
|
return isThisAwesome;
|
|
}
|
|
|
|
var x : boolean = veryOptimistic(true);
|
|
var y : boolean = veryOptimistic(false); // error
|
|
|
|
function veryPessimistic(isThisAwesome: true): boolean {
|
|
return !isThisAwesome; // test bool conversion
|
|
}
|
|
|
|
var x : boolean = veryPessimistic(true);
|
|
var y : boolean = veryPessimistic(false); // error
|
|
|
|
type MyOwnBooleanLOL = true | false
|
|
|
|
function bar(x: MyOwnBooleanLOL): false {
|
|
if (x) {
|
|
return x;
|
|
} else {
|
|
return !x;
|
|
}
|
|
}
|
|
|
|
bar(true);
|
|
bar(false);
|
|
bar(1); // error
|
|
|
|
function alwaysFalsy(x: boolean): false {
|
|
if (x) {
|
|
return !x;
|
|
} else {
|
|
return x;
|
|
}
|
|
}
|