Created
October 28, 2018 02:05
-
-
Save tkssharma/2c0dd675068ced4415ad786130c17dc5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Book { | |
type: "book"; | |
isbn: string; | |
page: number; | |
} | |
interface Movie { | |
type: "movie"; | |
lengthMinutes: number; | |
} | |
let hobby: Movie = { type: "movie", lengthMinutes: 120 }; | |
function showHobby(hobby: Book | Movie): void { | |
if (hobby.type === "movie") { | |
console.log("Long movie of " + hobby.lengthMinutes); | |
} else { | |
console.log("A book of few pages: " + hobby.page); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment