Created
September 1, 2017 00:18
-
-
Save brandonbloom/494d46eaf5851646c3eb8733bfaf7035 to your computer and use it in GitHub Desktop.
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
type Base = { | |
x: number, | |
}; | |
type Derived = Base & { | |
y: number, | |
}; | |
let to = <T>(x: T): T => x; | |
let f = (): Base => { | |
return { x: 5 } as Derived; // No error. | |
}; | |
let g = (): Base => { | |
return <Derived>{ x: 5 }; // No error. | |
}; | |
let h = (): Base => { | |
return to<Derived>({ x: 5 }); // Propery 'y' is missing! | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment