Skip to content

Instantly share code, notes, and snippets.

@kurogelee
Last active April 19, 2018 15:14
Show Gist options
  • Save kurogelee/be28449096d108ef8e8b4c80b051f355 to your computer and use it in GitHub Desktop.
Save kurogelee/be28449096d108ef8e8b4c80b051f355 to your computer and use it in GitHub Desktop.
TypeScriptで匿名クラス・内部クラス ref: https://qiita.com/kurogelee/items/fd7b86ba5d5660180bb3
class Base {
public static create() {
return new class extends Base {
constructor() {
super("XXX");
}
}();
}
constructor(private value: string) {
}
public methodA() {
console.log("A" + this.value);
}
}
const v = Base.create();
v.methodA();
class Base {
public static Inner = class extends Base {
public method() {
return 1;
}
};
}
class Base {
public static Inner = class extends Base {
public method() {
return 1;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment