|
| 1 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(16,1): error TS2322: Type 'X<void>' is not assignable to type 'X<number>'. |
| 2 | + Type 'void' is not assignable to type 'number'. |
| 3 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(17,1): error TS2322: Type 'X<number | void>' is not assignable to type 'X<number>'. |
| 4 | + Type 'number | void' is not assignable to type 'number'. |
| 5 | + Type 'void' is not assignable to type 'number'. |
| 6 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(18,1): error TS2322: Type 'Y<number>' is not assignable to type 'X<number>'. |
| 7 | + Types of property 'value' are incompatible. |
| 8 | + Type 'number | undefined' is not assignable to type 'number'. |
| 9 | + Type 'undefined' is not assignable to type 'number'. |
| 10 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(19,1): error TS2741: Property 'value' is missing in type '{ done: true; }' but required in type 'X<number>'. |
| 11 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(21,19): error TS2322: Type 'undefined' is not assignable to type 'number'. |
| 12 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(22,19): error TS2322: Type 'undefined' is not assignable to type 'number'. |
| 13 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(23,19): error TS2322: Type 'void' is not assignable to type 'number'. |
| 14 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(25,1): error TS2322: Type 'X<number>' is not assignable to type 'X<void>'. |
| 15 | + Type 'number' is not assignable to type 'void'. |
| 16 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(26,1): error TS2322: Type 'X<number | void>' is not assignable to type 'X<void>'. |
| 17 | + Type 'number | void' is not assignable to type 'void'. |
| 18 | + Type 'number' is not assignable to type 'void'. |
| 19 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(27,1): error TS2322: Type 'Y<number>' is not assignable to type 'X<void>'. |
| 20 | + Types of property 'value' are incompatible. |
| 21 | + Type 'number | undefined' is not assignable to type 'void'. |
| 22 | + Type 'number' is not assignable to type 'void'. |
| 23 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(29,19): error TS2322: Type 'number' is not assignable to type 'void'. |
| 24 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(44,1): error TS2322: Type 'X<void>' is not assignable to type 'Y<number>'. |
| 25 | + Types of property 'value' are incompatible. |
| 26 | + Type 'void' is not assignable to type 'number | undefined'. |
| 27 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(45,1): error TS2322: Type 'X<number | void>' is not assignable to type 'Y<number>'. |
| 28 | + Types of property 'value' are incompatible. |
| 29 | + Type 'number | void' is not assignable to type 'number | undefined'. |
| 30 | + Type 'void' is not assignable to type 'number | undefined'. |
| 31 | +tests/cases/conformance/types/members/typesWithVoidProperty.ts(50,19): error TS2322: Type 'void' is not assignable to type 'number | undefined'. |
| 32 | + |
| 33 | + |
| 34 | +==== tests/cases/conformance/types/members/typesWithVoidProperty.ts (14 errors) ==== |
| 35 | + interface X<T> { |
| 36 | + done: true; |
| 37 | + value: T; |
| 38 | + } |
| 39 | + |
| 40 | + interface Y<T> { |
| 41 | + done: true; |
| 42 | + value?: T; |
| 43 | + } |
| 44 | + |
| 45 | + declare let a: X<number>; |
| 46 | + declare let b: X<void>; |
| 47 | + declare let c: X<number | void>; |
| 48 | + declare let d: Y<number>; |
| 49 | + |
| 50 | + a = b; // not allowed because `value` must be `number` |
| 51 | + ~ |
| 52 | +!!! error TS2322: Type 'X<void>' is not assignable to type 'X<number>'. |
| 53 | +!!! error TS2322: Type 'void' is not assignable to type 'number'. |
| 54 | + a = c; // not allowed because `value` must be `number` |
| 55 | + ~ |
| 56 | +!!! error TS2322: Type 'X<number | void>' is not assignable to type 'X<number>'. |
| 57 | +!!! error TS2322: Type 'number | void' is not assignable to type 'number'. |
| 58 | +!!! error TS2322: Type 'void' is not assignable to type 'number'. |
| 59 | + a = d; // not allowed because `value` must be `number` |
| 60 | + ~ |
| 61 | +!!! error TS2322: Type 'Y<number>' is not assignable to type 'X<number>'. |
| 62 | +!!! error TS2322: Types of property 'value' are incompatible. |
| 63 | +!!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. |
| 64 | +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. |
| 65 | + a = { done: true }; // not allowed because `value` is not optional (non-`void`) |
| 66 | + ~ |
| 67 | +!!! error TS2741: Property 'value' is missing in type '{ done: true; }' but required in type 'X<number>'. |
| 68 | +!!! related TS2728 tests/cases/conformance/types/members/typesWithVoidProperty.ts:3:5: 'value' is declared here. |
| 69 | + a = { done: true, value: 1 }; // allowed because `value` must be `number` |
| 70 | + a = { done: true, value: undefined }; // not allowed because `value` must be `number` |
| 71 | + ~~~~~ |
| 72 | +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. |
| 73 | +!!! related TS6500 tests/cases/conformance/types/members/typesWithVoidProperty.ts:3:5: The expected type comes from property 'value' which is declared here on type 'X<number>' |
| 74 | + a = { done: true, value: undefined as undefined }; // not allowed because `value` must be `number` |
| 75 | + ~~~~~ |
| 76 | +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. |
| 77 | +!!! related TS6500 tests/cases/conformance/types/members/typesWithVoidProperty.ts:3:5: The expected type comes from property 'value' which is declared here on type 'X<number>' |
| 78 | + a = { done: true, value: undefined as void }; // not allowed because `value` must be `number` |
| 79 | + ~~~~~ |
| 80 | +!!! error TS2322: Type 'void' is not assignable to type 'number'. |
| 81 | +!!! related TS6500 tests/cases/conformance/types/members/typesWithVoidProperty.ts:3:5: The expected type comes from property 'value' which is declared here on type 'X<number>' |
| 82 | + |
| 83 | + b = a; // not allowed because `value` must be `void` |
| 84 | + ~ |
| 85 | +!!! error TS2322: Type 'X<number>' is not assignable to type 'X<void>'. |
| 86 | +!!! error TS2322: Type 'number' is not assignable to type 'void'. |
| 87 | + b = c; // not allowed because `value` must be `void` |
| 88 | + ~ |
| 89 | +!!! error TS2322: Type 'X<number | void>' is not assignable to type 'X<void>'. |
| 90 | +!!! error TS2322: Type 'number | void' is not assignable to type 'void'. |
| 91 | +!!! error TS2322: Type 'number' is not assignable to type 'void'. |
| 92 | + b = d; // not allowed because `value` must be `void` |
| 93 | + ~ |
| 94 | +!!! error TS2322: Type 'Y<number>' is not assignable to type 'X<void>'. |
| 95 | +!!! error TS2322: Types of property 'value' are incompatible. |
| 96 | +!!! error TS2322: Type 'number | undefined' is not assignable to type 'void'. |
| 97 | +!!! error TS2322: Type 'number' is not assignable to type 'void'. |
| 98 | + b = { done: true }; // allowed because `value` is optional due to `void` |
| 99 | + b = { done: true, value: 1 }; // not allowed because `value` must be `void` |
| 100 | + ~~~~~ |
| 101 | +!!! error TS2322: Type 'number' is not assignable to type 'void'. |
| 102 | +!!! related TS6500 tests/cases/conformance/types/members/typesWithVoidProperty.ts:3:5: The expected type comes from property 'value' which is declared here on type 'X<void>' |
| 103 | + b = { done: true, value: undefined }; // allowed because `value` can be `undefined` (assignable to `void`) |
| 104 | + b = { done: true, value: undefined as undefined }; // allowed because `value` can be `undefined` (assignable to `void`) |
| 105 | + b = { done: true, value: undefined as void }; // allowed because `value` must be `void` |
| 106 | + |
| 107 | + c = a; // allowed because `value` can be `number` |
| 108 | + c = b; // allowed because `value` can be `void` |
| 109 | + c = d; // allowed because `value` can be `undefined` |
| 110 | + c = { done: true }; // allowed because `value` is optional due to `void` |
| 111 | + c = { done: true, value: 1 }; // allowed because `value` can be `number` |
| 112 | + c = { done: true, value: undefined }; // allowed because `value` can be `undefined` (assignable to `void`) |
| 113 | + c = { done: true, value: undefined as undefined }; // allowed because `value` can be `undefined` (assignable to `void`) |
| 114 | + c = { done: true, value: undefined as void }; // allowed because `value` can be `void` |
| 115 | + |
| 116 | + d = a; // allowed because `value` must be `number | void` |
| 117 | + d = b; // not allowed because `value` must be `undefined`, and `void` is a supertype of `undefined` |
| 118 | + ~ |
| 119 | +!!! error TS2322: Type 'X<void>' is not assignable to type 'Y<number>'. |
| 120 | +!!! error TS2322: Types of property 'value' are incompatible. |
| 121 | +!!! error TS2322: Type 'void' is not assignable to type 'number | undefined'. |
| 122 | + d = c; // not allowed allowed because `value` must be `undefined`, and `void` is a supertype of `undefined` |
| 123 | + ~ |
| 124 | +!!! error TS2322: Type 'X<number | void>' is not assignable to type 'Y<number>'. |
| 125 | +!!! error TS2322: Types of property 'value' are incompatible. |
| 126 | +!!! error TS2322: Type 'number | void' is not assignable to type 'number | undefined'. |
| 127 | +!!! error TS2322: Type 'void' is not assignable to type 'number | undefined'. |
| 128 | + d = { done: true }; // allowed because `value` is optional |
| 129 | + d = { done: true, value: 1 }; // allowed because `value` can be `number` |
| 130 | + d = { done: true, value: undefined }; // allowed because `value` can be `undefined` |
| 131 | + d = { done: true, value: undefined as undefined }; // allowed because `value` can be `undefined` |
| 132 | + d = { done: true, value: undefined as void }; // not allowed because `value` can be `undefined`, and `void` is a supertype of `undefined |
| 133 | + ~~~~~ |
| 134 | +!!! error TS2322: Type 'void' is not assignable to type 'number | undefined'. |
| 135 | +!!! related TS6500 tests/cases/conformance/types/members/typesWithVoidProperty.ts:8:5: The expected type comes from property 'value' which is declared here on type 'Y<number>' |
| 136 | + |
0 commit comments