Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface Type<T> {
- new (...args): T;
- }
- interface Base {}
- interface Identifiable {}
- export function IdentifiableSubclass<T extends Base>(SuperClass: Type<T>) {
- class C extends (<Type<Base>>SuperClass) {
- // constructor(...args) {
- // super(...args);
- // return new Proxy(this, {
- // get(target, name) {
- // return target[name];
- // }
- // });
- // }
- }
- return <Type<Identifiable & T>>C;
- }
- @Component({...})
- class HeroesComponent {
- constructor(public heroService: HeroService) {}
- }
- const HeroesComponentLogged = IdentifiableSubclass(HeroesComponent);
- export { HeroesComponentLogged as HeroesComponent };
- class HeroService {
- public sayGoodbye() {
- console.log("Goodbye");
- }
- }
- class HeroComponent {
- constructor(public heroService: HeroService) {
- }
- }
- const IdentifiedHeroComponent = IdentifiableSubclass(HeroComponent);
- let identified = new IdentifiedHeroComponent(new HeroService());
- identified.heroService.sayGoodbye();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement