Files
test-repo/tests/flow/optional/nullable.js
T
Christopher Chedeau 3375cfe605 Move tests around (#454)
* 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
2017-01-24 14:35:37 -08:00

50 lines
952 B
JavaScript

/* @flow */
function optionalNullable1(x: {y?: ?number}) {
if (x.y !== null && x.y !== undefined) {
x.y++;
}
}
function optionalNullable2(x: {y?: ?number}) {
if (x.y !== undefined && x.y !== null) {
x.y++;
}
}
function optionalNullable3(x: {y?: ?number}) {
if (!(x.y !== null && x.y !== undefined)) {
x.y++; // should error
}
}
function optionalNullable4(x: {y?: ?number}) {
if (!(x.y !== undefined && x.y !== null)) {
x.y++; // should error
}
}
function optionalNullable5(x: {y?: ?number}) {
if (x.y === null || x.y === undefined) {
x.y++; // should error
}
}
function optionalNullable6(x: {y?: ?number}) {
if (x.y === undefined || x.y === null) {
x.y++; // should error
}
}
function optionalNullable7(x: {y?: ?number}) {
if (!(x.y === null || x.y === undefined)) {
x.y++;
}
}
function optionalNullable8(x: {y?: ?number}) {
if (!(x.y === undefined || x.y === null)) {
x.y++;
}
}