Skip to content

Commit 69c30a0

Browse files
committed
Add regression tests
1 parent ffab267 commit 69c30a0

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//// [excessPropertyCheckWithEmptyObject.ts]
2+
// Repro from #14910
3+
4+
// Excess property error expected here
5+
Object.defineProperty(window, "prop", { value: "v1.0.0", readonly: false });
6+
7+
interface A { x?: string }
8+
9+
// Excess property error expected here
10+
let a: A & ThisType<any> = { y: 10 };
11+
12+
interface Empty {}
13+
14+
// Excess property error expected here
15+
let x: Empty & { x: number } = { y: "hello" };
16+
17+
18+
//// [excessPropertyCheckWithEmptyObject.js]
19+
// Repro from #14910
20+
// Excess property error expected here
21+
Object.defineProperty(window, "prop", { value: "v1.0.0", readonly: false });
22+
// Excess property error expected here
23+
var a = { y: 10 };
24+
// Excess property error expected here
25+
var x = { y: "hello" };
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Repro from #14910
2+
3+
// Excess property error expected here
4+
Object.defineProperty(window, "prop", { value: "v1.0.0", readonly: false });
5+
6+
interface A { x?: string }
7+
8+
// Excess property error expected here
9+
let a: A & ThisType<any> = { y: 10 };
10+
11+
interface Empty {}
12+
13+
// Excess property error expected here
14+
let x: Empty & { x: number } = { y: "hello" };

0 commit comments

Comments
 (0)