Skip to content

Instantly share code, notes, and snippets.

@starbeast
Created June 4, 2017 14:22
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 starbeast/16d080ebd3612172384178312965b036 to your computer and use it in GitHub Desktop.
Save starbeast/16d080ebd3612172384178312965b036 to your computer and use it in GitHub Desktop.
Mixin with constraints
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