TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)
Code
I'm new to typescript and I'm wondering why not typescript add the class shape interface likes example below?
interface InstanceInterface {
foo: string;
bar(): string;
}
interface ClassInterface {
// the constructor shape
new (foo: string): InstanceInterface;
// default static method
baz(): void {
console.log('I come from interface.')
}
}
// We get hints guiding us to implement the constructor and static properties and static methods.
class Cls: ClassInterface implements InstanceInterface {
constructor(foo: string) {
this.foo = foo
}
static baz(): void {
console.log('I override the interface baz.')
}
foo: string
bar(): string {
return this.foo
}
}
As I know, Java8 added the static method defining and default implements.
TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)
Code
I'm new to typescript and I'm wondering why not typescript add the class shape interface likes example below?
As I know, Java8 added the static method defining and default implements.