Created
July 9, 2017 10:05
-
-
Save vvakame/97203c38c6e44060c4621e45c1ed13b7 to your computer and use it in GitHub Desktop.
open https://www.typescriptlang.org/play/ & paste this code.
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 Hello { | |
hello(): string; | |
} | |
interface Named { | |
name: string; | |
} | |
function parrot<T extends Named>(obj: T): T { | |
return obj; | |
} | |
parrot({ | |
name: "TypeScript", | |
}); | |
parrot({ | |
name: "TypeScript", | |
age: 5, | |
}); | |
parrot({ | |
name: "TypeScript", | |
age: function () { }, | |
}); | |
parrot({ | |
name: "TypeScript", | |
sayHello() { | |
console.log(`Hello, ${this.name}`); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment