Defining TypeScript callback type
To go one step further, you could declare a type pointer to a function signature like:
interface myCallbackType { (myArgument: string): void }
and use it like this:
public myCallback : myCallbackType;
I just found something in the TypeScript language specification, it's fairly easy. I was pretty close.
the syntax is the following:
public myCallback: (name: type) => returntype;
In my example, it would be
class CallbackTest
{
public myCallback: () => void;
public doWork(): void
{
//doing some work...
this.myCallback(); //calling callback
}
}
As a type alias:
type MyCallback = (name: type) => returntype;