-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Hot reloading breaks when encountering Typescript error #8667
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
Comments
Hello, I have the same issue, but seems that this comment resolves it: |
Having this same issue and the above commend unfortunately didn't fix it |
I'm having this issue as well. Linked comment above did not work on Windows. |
Can't reproduce it on macOS 10.15 |
Same problem in macOS 10.15 |
I have a similar problem, maybe not be the exact same problem, but I wonder if it's related. My problem is that if I have a TypeScript error in a file which isn't actually imported (yet or any more) by any other module descending from the entry point, saving it doesn't trigger recompiling. For the recompiling to start, I have to go to a file that is actually imported somewhere in the import tree starting from index.tsx and just save it (without changes). A bit annoying, while not the biggest of problems. |
I think the problem is that the TS loader did not generate a new .js file in this case due to syntax error, etc. therefore the webpack devserver did not pick up any file changes. not sure what the best approach is to solving this. and possibly barking at the wrong tree here since it's more of a TS and webpack issue. |
Similar to me. Should I post to the TS repo? Crash Error: |
Facing this same issue:
|
Having the same issue.
|
Me too having almost the same issue. Hope the team fix these issues soon. Thanks :) |
Having the same issue with |
Same with both |
Having the same issue with |
Will that be fixed until next year at least? |
It's driving me crazy, at 04:44AM |
So, is there any way for temporary fixing this issue? |
Same |
Works for me in macOS 10.15 when using |
linux mint, adding --reset-cache worked for me:
|
Hey, any solution to windows. I added reset-cache and still not working. Its really hectic to restart on each error. 😢Is there any workaround, would be really helpfull |
The same problem still happening... |
Guys, there seems to be a silly (but ugly) workaround.
|
Still happening. |
same |
same here this worked for me: #8667 (comment) |
Can someone at least acknowledge the people here? I too am having this problem. |
Same issue |
I have the same issue aswell. But the solution from @sanojck seems to work:
Although i would love if the create react app fixed this as fast as possible |
sanockj's solution worked. Then I realized that it was not auto-loading when the edited files were the 'index' files, such as ../../MyComponent/index.ts. Edit: this was not true. It was happening on other files. I could be wrong, but it mainly happened on newer files. Or also on files not being used elsewhere in the project? |
Solution posted by @sanojck works for me a lot of the time, but not always. It would be really nice if this issue was fixed entirely.
|
+1 |
I
While I appreciate the effort from everybody to provide workarounds, at that point it will probably take me less time to hit control+c up arrow and then enter than start playing with file modifications |
still happening |
Encountering the same error on .ts files, Hot reloading seems to work on .tsx however |
still happening |
I am having the same issue as others, I tried all "solutions" and none of them work. If I make one small TS mistake, I have to restart npm just to see any new changes I make, every single time. React: 17.0.1 and 17.0.2 Update, I did further testing and discovered this which "fixed" it for me: If I import a file but don't actually implement it in my component, TS will report errors as usual if there are any, but any changes I make — whether or not I fix the error — will not hot reload. However, when I do implement the imported file, such as putting it in my component as a var in a console.log, it will hot reload just fine. This was confusing because I had imported a file that already had an error in it, but I never actually implemented it in my component because of the error, and at this point, hot reloading wouldn't work. |
@danjguzman Thanks for the follow up. I my case, the issue occurred while I was working on a file I didn't even import anywhere at all. Typescript was finding issues on save, making me forget the module is still not imported anywhere. After importing the module causing the issues, hot reloading, as expected, works again. |
Looks like this issue was started during react-scripts 3.x, and all of the comments above that mention a version mention 3.x. However, this is happening for me on 4.0.3. Can anyone else confirm if they are having this issue in 4.x?
|
I've tested it again with the latest scripts, using the default files generated by
// file index.tsx
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
); If you add and remove a non-existent prop to
|
By "didn't affect" do you mean that your 4.x usage didn't change what is for you, currently broken behavior (it's "still" not working)? Or that those 3 things were working for you, and they still are working?
If your changes are in an |
They were working, that is once the error was fixed, the CSS filled again and App returning a real component, the changes were reflected in the browser. However, it was just a quick trying, I have the feeling you're right, maybe there's something that stops to make it work.
Thanks, I'll investigate a bit further. |
I have created a repo that is a fresh CRA install ( cra-bug.mp4 |
Same issue, nothing worked for me except re-starting the development server. |
Well guys I wrote a simple script applying the @sanojck 's solution. So it is working in my projects almost all time, So I do not have to pressing Ctrl + c and run the project again every time the app frozen... The script: |
Hi all, found a quick and effective fix that will hopefully work for all of you. Like others, I had found that re-saving the index.tsx would trigger the reload. I revisited the tsconfig.json and changed the 'include' parameter from:
to:
This ensured that the index file was being tracked as the root and then triggered the reload. Strange that this is necessary but it worked! |
For those encountering index.* not reloading, that is a separate issue: #9984 |
To be clear - I was experiencing the issue with none of of my components/pages hot reloading. Could be I misunderstood my issue versus others however - thanks for highlighting. |
I am encountering what appears to be the same issue. I am using WIndows Environment Info:
|
Same issue (4.03). Ubuntu. |
Describe the bug
I am having exactly same issue as metioned in #8055
Since that issue is now closed, I will just re-describe the issue again here.
Hot reloading seems to stop working when a Typescript compilation error is encountered.
Any subsequent code changes would not trigger hot reloading after that, even if I fix the lines that would cause compile errror.
I need to actually close and restart the dev server in order to see my changes reflected.
Which terms did you search for in User Guide?
Typescript, Hot reloading
Environment
Steps to reproduce
create-react-app react-app --template typescript
cd react-app
yarn start
src/App.tsx
and save it to trigger compilation errorsrc/App.tsx
and save ityarn start
again to see changes get reflectedExpected behavior
Re-compile and hot reload on every save, just like when using
create-react-app
without the--template typescript
flagThe text was updated successfully, but these errors were encountered: