Skip to content

Commit

Permalink
Add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg authored and DanielRosenwasser committed Dec 10, 2018
1 parent c32a48e commit 6234e10
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/cases/compiler/objectLiteralExcessProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,20 @@ interface Indexed {
var b10: Indexed = { 0: { }, '1': { } }; // ok

var b11: Indexed = { 0: { colour: "blue" } }; // nested object literal still errors

// Repros inspired by #28752

function test<T extends IFoo>() {
// No excess property checks on generic types
const obj1: T = { name: "test" };
// No excess property checks on intersections involving generics
const obj2: T & { prop: boolean } = { name: "test", prop: true };
// Excess property checks only on non-generic parts of unions
const obj3: T | { prop: boolean } = { name: "test", prop: true };
// Excess property checks only on non-generic parts of unions
const obj4: T & { prop: boolean } | { name: string } = { name: "test", prop: true };
// No excess property checks when union includes 'object' type
const obj5: object | { x: string } = { z: 'abc' }
// The 'object' type has no effect on intersections
const obj6: object & { x: string } = { z: 'abc' }
}

0 comments on commit 6234e10

Please sign in to comment.