|
| 1 | +tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts(4,23): error TS2304: Cannot find name 'window'. |
| 2 | +tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts(4,58): error TS2345: Argument of type '{ value: string; readonly: boolean; }' is not assignable to parameter of type 'PropertyDescriptor & ThisType<any>'. |
| 3 | + Object literal may only specify known properties, and 'readonly' does not exist in type 'PropertyDescriptor & ThisType<any>'. |
| 4 | +tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts(9,30): error TS2322: Type '{ y: number; }' is not assignable to type 'A & ThisType<any>'. |
| 5 | + Object literal may only specify known properties, and 'y' does not exist in type 'A & ThisType<any>'. |
| 6 | +tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts(14,34): error TS2322: Type '{ y: string; }' is not assignable to type 'Empty & { x: number; }'. |
| 7 | + Object literal may only specify known properties, and 'y' does not exist in type 'Empty & { x: number; }'. |
| 8 | + |
| 9 | + |
| 10 | +==== tests/cases/compiler/excessPropertyCheckWithEmptyObject.ts (4 errors) ==== |
| 11 | + // Repro from #14910 |
| 12 | + |
| 13 | + // Excess property error expected here |
| 14 | + Object.defineProperty(window, "prop", { value: "v1.0.0", readonly: false }); |
| 15 | + ~~~~~~ |
| 16 | +!!! error TS2304: Cannot find name 'window'. |
| 17 | + ~~~~~~~~~~~~~~~ |
| 18 | +!!! error TS2345: Argument of type '{ value: string; readonly: boolean; }' is not assignable to parameter of type 'PropertyDescriptor & ThisType<any>'. |
| 19 | +!!! error TS2345: Object literal may only specify known properties, and 'readonly' does not exist in type 'PropertyDescriptor & ThisType<any>'. |
| 20 | + |
| 21 | + interface A { x?: string } |
| 22 | + |
| 23 | + // Excess property error expected here |
| 24 | + let a: A & ThisType<any> = { y: 10 }; |
| 25 | + ~~~~~ |
| 26 | +!!! error TS2322: Type '{ y: number; }' is not assignable to type 'A & ThisType<any>'. |
| 27 | +!!! error TS2322: Object literal may only specify known properties, and 'y' does not exist in type 'A & ThisType<any>'. |
| 28 | + |
| 29 | + interface Empty {} |
| 30 | + |
| 31 | + // Excess property error expected here |
| 32 | + let x: Empty & { x: number } = { y: "hello" }; |
| 33 | + ~~~~~~~~~~ |
| 34 | +!!! error TS2322: Type '{ y: string; }' is not assignable to type 'Empty & { x: number; }'. |
| 35 | +!!! error TS2322: Object literal may only specify known properties, and 'y' does not exist in type 'Empty & { x: number; }'. |
| 36 | + |
0 commit comments