Last active
July 19, 2016 11:37
-
-
Save oliverlundquist/9934b4bd992e832bb92b996b1d00dda0 to your computer and use it in GitHub Desktop.
Type Safety
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
type Mixtype = String|Number; | |
class SomeClass<T extends Mixtype> { | |
somemethod(arg: T): T { | |
return arg; | |
} | |
} | |
var somevar = new SomeClass<Number>(); | |
console.log(somevar.somemethod(123)); | |
console.log(somevar.somemethod('hey')); // error | |
console.log(somevar.somemethod(true)); // error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment