Last active
March 28, 2017 06:15
-
-
Save Ibro/f07738923d40753ec7a30449adeb5f79 to your computer and use it in GitHub Desktop.
TypeScript intersection types properties overlap error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface X { | |
c: string; | |
d: string; | |
} | |
interface Y { | |
c: number; | |
e: string | |
} | |
type XY = X & Y; | |
type YX = Y & X; | |
let p: XY; | |
let q: XY; | |
p.c = 4; // Error: Type '4' is not assignable to type 'string & number' | |
q.c = 3; // Error: Type '3' is not assignable to type 'string & number' | |
p.c = 'text'; // Error: Type 'text' is not assignable to type 'string & number' | |
q.c = 'text'; // Error: Type 'text' is not assignable to type 'string & number' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment