Skip to content

Weak type detection for intersection types #19296

@AlexeyMz

Description

@AlexeyMz

TypeScript Version: 2.6.0-dev.20171018

Code

interface X { x: string }
interface Y { y: number }
interface Z { z?: boolean }

type XY = X & Y;
const xy: XY = {x: 'x', y: 10};

const z1: Z = xy;
// (1) compiles without any errors

const z2: Z = xy as Pick<XY, keyof XY>;
// (2) produces error: Type 'Pick<X & Y, "x" | "y">' has no properties in common with type 'Z'.

Expected behavior:
(1) should produce an error similar to (2) because there are no common properties for XY and Z types.

Actual behavior:
(1) compiles without any errors.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions