首页 > 解决方案 > ts-node 抛出无关的奇怪错误,但使用 tsc 时没有抛出错误

问题描述

当我运行 ts-node 时,它​​会抛出这些错误

src/api/role.ts:2:58 - error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
                                                           ~~~~~~~~~~~~~
src/api/role.ts:9:64 - error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
9 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {

但是在我的代码中找不到错误中提到的所有行。我尝试运行 tsc,它没有显示这些错误。所有这些错误仅在我使用 ts-node 时发生。

标签: typescriptts-node

解决方案


我更改了我_moduleAliases的 package.json 以引用构建的脚本。它可以工作,但是对于我的脚本中的每一个更改,我都需要运行tsc.


推荐阅读