Open its-dibo opened 2 months ago
in docs there is an example to override a method like this
get base(): CrudController<Hero> { return this; } @Override() getMany( @ParsedRequest() req: CrudRequest, ) { return this.base.getManyBase(req); }
however, the base methods such as getManyBase is typed to return a promise or undefined so, the previous snippet makes TS to give this error
getManyBase
Cannot invoke an object which is possibly 'undefined'.ts(2722)
we can make an ugly workaround and edit our code to be
return this.base.getManyBase?.(req);
this also makes TS complain again because the overrides method i.e. getMany() should return Promise only, not promise or undefined
getMany()
@its-dibo Which TS version are you using?
Which TS version are you using?
5.4.5
in docs there is an example to override a method like this
however, the base methods such as
getManyBase
is typed to return a promise or undefined so, the previous snippet makes TS to give this errorwe can make an ugly workaround and edit our code to be
this also makes TS complain again because the overrides method i.e.
getMany()
should return Promise only, not promise or undefined