-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Description
TypeScript Version: 2.1.5
Code
interface A {
x: string
}
interface B {
a: A;
}
interface C {
c: number;
}
type D = B & C;
let a: B = {a: {x: 'hello'}}; // ok
let b: B = {a: {x: 2}}; // error - types of property x are incompatible
let c: B = {a: {x: 'hello', y: 2}}; // error - y does not exist in type A
let d: D = {a: {x: 'hello'}, c: 5}; // ok
let e: D = {a: {x: 2}, c: 5}; // error - types of property x are incompatible
let f: D = {a: {x: 'hello', y: 2}, c: 5}; // should be an error?: y does not exist in type A
Expected behavior:
Excess property checking should cause a compiler error for the last example.
Actual behavior:
Last example compiles without error.
mattmccutchen, xcatliu and luxalpa
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript