Converting an Express JS server to TS, and previously functioning JS conditionals are now throwing weird errors.
Example: if (req!.body?.userObj) req.session!.userObj = req.body!.userObj
Running with ts-node
works fine and there are no issues. But running tsc
to compile throws these errors:
error TS1109: Expression expected.
55 if (req!.body?.userObj) req.session!.userObj = req.body!.userObj
~
middleware/payloadHandle.ts:55:27 -
error TS1005: ':' expected.
55 if (req!.body?.userObj) req.session!.userObj = req.body!.userObj
您确保 TS 编译器已更新: npm i typescript@latest
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.