Last active
April 19, 2018 15:14
-
-
Save kurogelee/be28449096d108ef8e8b4c80b051f355 to your computer and use it in GitHub Desktop.
TypeScriptで匿名クラス・内部クラス ref: https://qiita.com/kurogelee/items/fd7b86ba5d5660180bb3
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
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(); | |
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
class Base { | |
public static Inner = class extends Base { | |
public method() { | |
return 1; | |
} | |
}; | |
} |
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
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