|
1 | 1 | tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(1,5): error TS2322: Type '""' is not assignable to type 'object & string'.
|
2 | 2 | Type '""' is not assignable to type 'object'.
|
3 |
| -tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(3,1): error TS2322: Type 'string' is not assignable to type 'object & string'. |
| 3 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(3,5): error TS2322: Type '123' is not assignable to type 'object & {}'. |
| 4 | + Type '123' is not assignable to type 'object'. |
| 5 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(4,1): error TS2322: Type 'string' is not assignable to type 'object & string'. |
4 | 6 | Type 'string' is not assignable to type 'object'.
|
| 7 | +tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts(8,38): error TS2322: Type '{ bar: string; }' is not assignable to type 'object & { err: string; }'. |
| 8 | + Object literal may only specify known properties, and 'bar' does not exist in type 'object & { err: string; }'. |
5 | 9 |
|
6 | 10 |
|
7 |
| -==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts (2 errors) ==== |
| 11 | +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts (4 errors) ==== |
8 | 12 | var a: object & string = ""; // error
|
9 | 13 | ~
|
10 | 14 | !!! error TS2322: Type '""' is not assignable to type 'object & string'.
|
11 | 15 | !!! error TS2322: Type '""' is not assignable to type 'object'.
|
12 | 16 | var b: object | string = ""; // ok
|
| 17 | + var c: object & {} = 123; // error |
| 18 | + ~ |
| 19 | +!!! error TS2322: Type '123' is not assignable to type 'object & {}'. |
| 20 | +!!! error TS2322: Type '123' is not assignable to type 'object'. |
13 | 21 | a = b; // error
|
14 | 22 | ~
|
15 | 23 | !!! error TS2322: Type 'string' is not assignable to type 'object & string'.
|
16 | 24 | !!! error TS2322: Type 'string' is not assignable to type 'object'.
|
17 | 25 | b = a; // ok
|
| 26 | + |
| 27 | + const foo: object & {} = {bar: 'bar'}; // ok |
| 28 | + const bar: object & {err: string} = {bar: 'bar'}; // error |
| 29 | + ~~~~~~~~~~ |
| 30 | +!!! error TS2322: Type '{ bar: string; }' is not assignable to type 'object & { err: string; }'. |
| 31 | +!!! error TS2322: Object literal may only specify known properties, and 'bar' does not exist in type 'object & { err: string; }'. |
18 | 32 |
|
0 commit comments