我的服务器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-类型