Reputation: 41087
I'm trying to define a method in the simple way:
method(arg: string): any {
// code
}
But it is not working.
If I define it like this then it works:
const method = ((arg: string) => {
// code
});
Why can't I define the method in the simple way?
Upvotes: 0
Views: 28
Reputation: 30082
Outside of a class, that syntax isn't valid. If you want to declare a named function, some other options are:
function method(arg: string) : any {
}
const method = function(arg: string) : any {
};
Upvotes: 2