Hi,
I was wondering if it's possible in some way to define a class method outside of the class.
Right now I've used the "JS" prototype syntax to split the class definition from the method definitions like this:
class Foo {
method: (arg: any) => any; // "prototype"-like
}
Foo.prototype.method = (arg: any): any => {
// Method implementation [...]
}
But I was wondering if TypeScript could officially support this kind of separation with a better syntax (let me know if this is currently possible or planned for future versions). Like this:
Foo::method = (arg: any): any => {
// Method implementation [...]
}
Or like this:
Foo::method(arg: any): any {
// Method implementation [...]
}
If possible I'd really love to see this syntax supported in TypeScript.
This way we can write some class definitions first, without having to use an interface to describe each of those, and then implement the details of the methods (or constructor).
I guess this is related to the ES6 standard, I'm not sure if you would do something similar in EcmaScript.
Hi,
I was wondering if it's possible in some way to define a class method outside of the class.
Right now I've used the "JS" prototype syntax to split the class definition from the method definitions like this:
But I was wondering if TypeScript could officially support this kind of separation with a better syntax (let me know if this is currently possible or planned for future versions). Like this:
Or like this:
If possible I'd really love to see this syntax supported in TypeScript.
This way we can write some class definitions first, without having to use an interface to describe each of those, and then implement the details of the methods (or constructor).
I guess this is related to the ES6 standard, I'm not sure if you would do something similar in EcmaScript.