forked from topcoder-platform/topcoder-react-utils
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
P2Important. Nice to have improvements and optimizations.Important. Nice to have improvements and optimizations.
Description
I guess, we should require the caller to specify expected type of asserted value, and make it clear to TS that this assertion / cast is done there.
react-utils/src/server/utils/errors.ts
Lines 124 to 134 in 73476cb
| export function assert( | |
| value: unknown, | |
| schema: joi.AnySchema, | |
| message = '', | |
| statusCode = CODES.BAD_REQUEST, | |
| ): void { | |
| const { error } = schema.validate(value, { abortEarly: false }); | |
| if (error) { | |
| fail(message.concat(message ? '\n' : '', error.message), statusCode); | |
| } | |
| } |
Update: After first tests, it seems problematic to do something useful here, both due to peculiarities of TS compiler and its support of asserts feature, and also due to the way express requests are typed.
Metadata
Metadata
Assignees
Labels
P2Important. Nice to have improvements and optimizations.Important. Nice to have improvements and optimizations.