ts节点dev-hot-reaload无法识别我在index.ts中的导入文件



我的服务器index.ts文件导入consoleColorFy.ts

consoleColorFy.ts

declare global {
interface Console {
redBg: TConsoleFn;
}
}
console["redBg"] = ...

现在我可以使用console.redBg()
它在大多数情况下运行良好,但当热重新加载某些服务器的文件时

我犯了这个错误。

Property 'redBg' does not exist on type 'Console'.
>> console.redBg("error", error);

首先导入的consoleColorFy.ts将始终有效,因为所有代码都从index.ts开始。

但当ts-node-dev通过更改代码来运行hot-reloaded时,它似乎只是返工了一些文件。它不认识我的consoleColorFy.ts哼……有什么建议吗?

"ts-node-dev --respawn --no-notify --rs src/index.ts --env=dev"

当我重新启动服务器时,它运行良好
或者当刷新的文件是index.ts

您可以添加--files,它对我有效。

https://github.com/TypeStrong/ts-node#missing-类型

最新更新