Trying to implement a fat arrow function with a nestjs decorator in a controller.
Can it be done in the following way :
@Controller()
export class AppController {
@Get()
findAll = (): string => 'This is coming from a fat arrow !';
}
When attempting this, TypeScript throws an error message:
Unable to resolve signature of property decorator when called as an expression
, indicating that it does not work as expected.
Preference lies on using fat arrow functions over the traditional function declaration:
@Controller()
export class AppController {
@Get()
findAll(): string {
return 'This is not comming from a fat arrow';
}
}
Hence the query about the feasibility of the first approach.