1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(59,13): error TS18050: The value 'undefined' cannot be used here.
tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(61,13): error TS18050: The value 'undefined' cannot be used here.
tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(63,14): error TS18050: The value 'undefined' cannot be used here.
tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts(65,14): error TS18050: The value 'undefined' cannot be used here.
==== tests/cases/conformance/types/typeRelationships/comparable/equalityStrictNulls.ts (4 errors) ====
function f1(x: string) {
if (x == undefined) {
}
if (x != undefined) {
}
if (x === undefined) {
}
if (x !== undefined) {
}
if (x == null) {
}
if (x != null) {
}
if (x === null) {
}
if (x !== null) {
}
if (undefined == x) {
}
if (undefined != x) {
}
if (undefined === x) {
}
if (undefined !== x) {
}
if (null == x) {
}
if (null != x) {
}
if (null === x) {
}
if (null !== x) {
}
}
function f2() {
if (undefined == undefined) {
}
if (undefined == null) {
}
if (null == undefined) {
}
if (null == null) {
}
}
function f3(a: number, b: boolean, c: { x: number }, d: number | string) {
if (a == null) {
}
if (b == null) {
}
if (c == null) {
}
if (d == null) {
}
}
function f4(x: number) {
if (x > undefined) {
~~~~~~~~~
!!! error TS18050: The value 'undefined' cannot be used here.
}
if (x < undefined) {
~~~~~~~~~
!!! error TS18050: The value 'undefined' cannot be used here.
}
if (x >= undefined) {
~~~~~~~~~
!!! error TS18050: The value 'undefined' cannot be used here.
}
if (x <= undefined) {
~~~~~~~~~
!!! error TS18050: The value 'undefined' cannot be used here.
}
}
function f5(x: string) {
switch(x) {
case null:
break;
case undefined:
break;
default:
return;
}
}
|