You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
Some of the backend controllers are typed incorrectly. express middleware functions should be typed as RequestHandler (can import from ‘express’) and one should always supply generic type arguments to specify the shape of the route params, response body, request body and query params.
Rationale
If you go to getSingleAgency and try to access req.body.nonsense, req.query.nonsense or req.params.nonsense, you can see that they are all either any or string, even though we know that these are undefined. this is because there are no generic type arguments to Request and Response, so everything defaults to any or string.
Some of the backend controllers are typed incorrectly. express middleware functions should be typed as RequestHandler (can import from ‘express’) and one should always supply generic type arguments to specify the shape of the route params, response body, request body and query params.
Rationale
If you go to
getSingleAgency
and try to accessreq.body.nonsense
,req.query.nonsense
orreq.params.nonsense
, you can see that they are all eitherany
orstring
, even though we know that these areundefined
. this is because there are no generic type arguments to Request and Response, so everything defaults to any or string.Example
https://github.com/opengovsg/FormSG/blob/f4db38bde03c59ec0b8856bfed08f0f31bdcb538/src/app/modules/submission/email-submission/email-submission.controller.ts#L34-L38
The text was updated successfully, but these errors were encountered: