Skip to content

Instantly share code, notes, and snippets.

@Ibro
Last active March 28, 2017 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ibro/f07738923d40753ec7a30449adeb5f79 to your computer and use it in GitHub Desktop.
Save Ibro/f07738923d40753ec7a30449adeb5f79 to your computer and use it in GitHub Desktop.
TypeScript intersection types properties overlap error
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