Skip to content

Instantly share code, notes, and snippets.

@brandonbloom
Created September 1, 2017 00:18
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 brandonbloom/494d46eaf5851646c3eb8733bfaf7035 to your computer and use it in GitHub Desktop.
Save brandonbloom/494d46eaf5851646c3eb8733bfaf7035 to your computer and use it in GitHub Desktop.
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