Skip to content

Excess properties warning with contextual type of I | object #16235

@ghost

Description

TypeScript Version: nightly (2.4.0-dev.20170602)

Code

interface I { x: number }
declare function f(payload: I | object): void;
f({ foo: "bar" });

Expected behavior:

No error.

Actual behavior:

src/a.ts(3,5): error TS2345: Argument of type '{ foo: string; }' is not assignable to parameter of type 'object | I'.
  Object literal may only specify known properties, and 'foo' does not exist in type 'object | I'.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions