|
| 1 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(7,1): error TS2454: Variable 'a' is used before being assigned. |
| 2 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(8,1): error TS2322: Type 'undefined' is not assignable to type 'object'. |
| 3 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(9,1): error TS2322: Type 'null' is not assignable to type 'object'. |
| 4 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(10,1): error TS2322: Type 'object | null' is not assignable to type 'object'. |
| 5 | + Type 'null' is not assignable to type 'object'. |
| 6 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(11,1): error TS2322: Type 'object | undefined' is not assignable to type 'object'. |
| 7 | + Type 'undefined' is not assignable to type 'object'. |
| 8 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(12,1): error TS2322: Type 'object | null | undefined' is not assignable to type 'object'. |
| 9 | + Type 'undefined' is not assignable to type 'object'. |
| 10 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(18,7): error TS2339: Property 'toString' does not exist on type 'never'. |
| 11 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(22,5): error TS2322: Type 'object | null' is not assignable to type 'object'. |
| 12 | + Type 'null' is not assignable to type 'object'. |
| 13 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(27,5): error TS2531: Object is possibly 'null'. |
| 14 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,5): error TS2532: Object is possibly 'undefined'. |
| 15 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,7): error TS2339: Property 'toString' does not exist on type 'never'. |
| 16 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,5): error TS2533: Object is possibly 'null' or 'undefined'. |
| 17 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,7): error TS2339: Property 'toString' does not exist on type 'never'. |
| 18 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,5): error TS2531: Object is possibly 'null'. |
| 19 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,7): error TS2339: Property 'toString' does not exist on type 'never'. |
| 20 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(41,5): error TS2532: Object is possibly 'undefined'. |
| 21 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,5): error TS2532: Object is possibly 'undefined'. |
| 22 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,7): error TS2339: Property 'toString' does not exist on type 'never'. |
| 23 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(47,5): error TS2531: Object is possibly 'null'. |
| 24 | + |
| 25 | + |
| 26 | +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts (19 errors) ==== |
| 27 | + |
| 28 | + var a: object |
| 29 | + declare var b: object | null |
| 30 | + declare var c: object | undefined |
| 31 | + declare var d: object | null | undefined |
| 32 | + var e: object | null |
| 33 | + a.toString; // error |
| 34 | + ~ |
| 35 | +!!! error TS2454: Variable 'a' is used before being assigned. |
| 36 | + a = undefined; // error |
| 37 | + ~ |
| 38 | +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. |
| 39 | + a = null; // error |
| 40 | + ~ |
| 41 | +!!! error TS2322: Type 'null' is not assignable to type 'object'. |
| 42 | + a = b; // error |
| 43 | + ~ |
| 44 | +!!! error TS2322: Type 'object | null' is not assignable to type 'object'. |
| 45 | +!!! error TS2322: Type 'null' is not assignable to type 'object'. |
| 46 | + a = c; // error |
| 47 | + ~ |
| 48 | +!!! error TS2322: Type 'object | undefined' is not assignable to type 'object'. |
| 49 | +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. |
| 50 | + a = d; // error |
| 51 | + ~ |
| 52 | +!!! error TS2322: Type 'object | null | undefined' is not assignable to type 'object'. |
| 53 | +!!! error TS2322: Type 'undefined' is not assignable to type 'object'. |
| 54 | + |
| 55 | + e = a; // ok |
| 56 | + a = e; // ok |
| 57 | + |
| 58 | + if (typeof b !== 'object') { |
| 59 | + b.toString(); // error, never |
| 60 | + ~~~~~~~~ |
| 61 | +!!! error TS2339: Property 'toString' does not exist on type 'never'. |
| 62 | + } |
| 63 | + |
| 64 | + if (typeof b === 'object') { |
| 65 | + a = b; // error, b is not narrowed |
| 66 | + ~ |
| 67 | +!!! error TS2322: Type 'object | null' is not assignable to type 'object'. |
| 68 | +!!! error TS2322: Type 'null' is not assignable to type 'object'. |
| 69 | + } |
| 70 | + |
| 71 | + if (typeof d === 'object') { |
| 72 | + b = d; // ok |
| 73 | + d.toString(); // error, object | null |
| 74 | + ~ |
| 75 | +!!! error TS2531: Object is possibly 'null'. |
| 76 | + } else { |
| 77 | + d.toString(); // error, undefined |
| 78 | + ~ |
| 79 | +!!! error TS2532: Object is possibly 'undefined'. |
| 80 | + ~~~~~~~~ |
| 81 | +!!! error TS2339: Property 'toString' does not exist on type 'never'. |
| 82 | + } |
| 83 | + |
| 84 | + if (d == null) { |
| 85 | + d.toString(); // error, undefined | null |
| 86 | + ~ |
| 87 | +!!! error TS2533: Object is possibly 'null' or 'undefined'. |
| 88 | + ~~~~~~~~ |
| 89 | +!!! error TS2339: Property 'toString' does not exist on type 'never'. |
| 90 | + } else { |
| 91 | + d.toString(); // object |
| 92 | + } |
| 93 | + |
| 94 | + if (d === null) { |
| 95 | + d.toString(); // error, null |
| 96 | + ~ |
| 97 | +!!! error TS2531: Object is possibly 'null'. |
| 98 | + ~~~~~~~~ |
| 99 | +!!! error TS2339: Property 'toString' does not exist on type 'never'. |
| 100 | + } else { |
| 101 | + d.toString(); // error, object | undefined |
| 102 | + ~ |
| 103 | +!!! error TS2532: Object is possibly 'undefined'. |
| 104 | + } |
| 105 | + |
| 106 | + if (typeof d === 'undefined') { |
| 107 | + d.toString(); // error, undefined |
| 108 | + ~ |
| 109 | +!!! error TS2532: Object is possibly 'undefined'. |
| 110 | + ~~~~~~~~ |
| 111 | +!!! error TS2339: Property 'toString' does not exist on type 'never'. |
| 112 | + } else { |
| 113 | + d.toString(); // error, object | null |
| 114 | + ~ |
| 115 | +!!! error TS2531: Object is possibly 'null'. |
| 116 | + } |
| 117 | + |
0 commit comments