TypeScriptでclassのinterfaceを定義する
https://gyazo.com/7f39846001d7d443235b4e2b71190b0a
code:typescript
abstract class Foo {
static greetings: string
abstract sayHello: () => void
abstract maybeNotImplementedProperty?: number
}
class Hoge implements Foo {
static greetings = 'Hello'
sayHello () {
console.log(Hoge.greetings)
}
}
class Fuga implements Foo {
static greetings = 'Bonjour'
sayHello () {
console.log(Fuga.greetings)
}
}
let instance: Foo = new Hoge()
instance = new Fuga()
instance.sayHello()