TypeScript-Sublime-Plugin: Plugin suddenly cannot build typescript files or find names unless Sublime 3 is restarted
Plugin works fine for a period of time, but after working for a while and changing/saving files, I notice all of the sudden some of my class names and other namespaces cannot be found. I can’t navigate to them with F12 (GoTo) and when I try to build a file, the compiler comes back with errors saying “Cannot find name InsertSomeNameHere
”
There appears to be no errors in the console once this happens. The only way to fix the issues is to shut down SublimeText and reopen it. After reopening Sublime, everything works as expecting and I can build all files that were open and also GoTo any name as normal. Some random time later, this happens again and I have to shutdown and restart the editor again.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 7
- Comments: 57 (36 by maintainers)
There are many things that cause tsserver to fail (adding a module, changing the component in a module from a class component to a function component, etc).
Fortunately, this cool plugin, https://github.com/randy3k/AutomaticPackageReloader, has a command for reloading any Sublime Text plugin.
Install AutomaticPackageReloader and add something like the following to
User/Default.sublime-commands
:Or, to your
sublime-keymap
file:This reloads the TypeScript package, and in most every case I’ve seen makes it actually start working again in a second or two. This is a lot easier and faster than restarting Sublime Text.
@DanielRosenwasser @zhengbli It might be good to add this solution to the documentation. If this issue is any indication the plugin crashes frequently (it certainly does in my experience) and it seems like there’s no one able to fix the crash issues.
I’d be glad to add this to the docs and submit a PR if people think it’s worth it.
I experienced similar issues, but once I moved away from NVM and N and installed a single version of node this issue went away.
Update 3/1/17 It’s actually node version 4 that fixed this issue. Not sure if NVM or N has any role to play.
This happens to me frequently as well. I’m temporarily using VSCode until its resolved (though I prefer Sublime).
For maintainers, as mentioned in a few other issues on here, I too wasn’t able to get logs to generate - but I can say that by monitoring
ps aux | grep typescript
that when things went south, there was at least 2+ tsservers running under sublime. Restarting sublime reduced that count back to exactly one.I’d settled for a quick tsserver restart from within sublime, but ideally fixed properly. Happy to debug, but need instructions on how to correctly activate the generation of the log files