Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts-node-dev hot reaload dose not recognize my import file in index.ts #304

Open
SuperWallaby opened this issue Mar 16, 2022 · 1 comment

Comments

@SuperWallaby
Copy link

My server index.ts file import consoleColorFy.ts

consoleColorFy.ts

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

Now i can use console.redBg().
It works well in most time but when hot-reload some server's file

I got this error.

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

consoleColorFy.ts, which is imported first, will always work because all code starts from index.ts.

But when ts-node-dev run hot-reloaded by change of code, it seems to only rework some file. and it dose not recognise my consoleColorFy.ts Hum.... any advice?

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

It works well when I restart server

ts-node-dev": "^1.1.1"

@deepakaggarwal7
Copy link

deepakaggarwal7 commented Oct 1, 2023

I'm facing a similar problem. I've a logger declared as global variable.

In app.ts

import {log, Logger} from 'bluelog'
declare global {
    var log: Logger
}
global.log = log
console.log('log', log)

In another file I've:
log("log something")

When the application starts, all logs work fine. If any error inducing code is added and then fixed, the terminal starts throwing log not found error. Then, again I have to exit and restart server, Hot reload is not able to find it. Sometimes it works too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants