Skip to content

Commit e7bb562

Browse files
committed
Add additional tests
1 parent f1b3c6e commit e7bb562

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/cases/compiler/objectLiteralExcessProperties.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,20 @@ interface Indexed {
3131
var b10: Indexed = { 0: { }, '1': { } }; // ok
3232

3333
var b11: Indexed = { 0: { colour: "blue" } }; // nested object literal still errors
34+
35+
// Repros inspired by #28752
36+
37+
function test<T extends IFoo>() {
38+
// No excess property checks on generic types
39+
const obj1: T = { name: "test" };
40+
// No excess property checks on intersections involving generics
41+
const obj2: T & { prop: boolean } = { name: "test", prop: true };
42+
// Excess property checks only on non-generic parts of unions
43+
const obj3: T | { prop: boolean } = { name: "test", prop: true };
44+
// Excess property checks only on non-generic parts of unions
45+
const obj4: T & { prop: boolean } | { name: string } = { name: "test", prop: true };
46+
// No excess property checks when union includes 'object' type
47+
const obj5: object | { x: string } = { z: 'abc' }
48+
// The 'object' type has no effect on intersections
49+
const obj6: object & { x: string } = { z: 'abc' }
50+
}

0 commit comments

Comments
 (0)