Created
June 4, 2017 14:22
-
-
Save starbeast/16d080ebd3612172384178312965b036 to your computer and use it in GitHub Desktop.
Mixin with constraints
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 IPoint { | |
x: number; | |
y: number; | |
} | |
const WithLocation = <T extends Constructor<IPoint>>(Base: T) => | |
class extends Base { | |
getLocation(): [number, number] { | |
return [this.x, this.y]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment