TL;DR
Allow running tsc in debug mode when using typescript-transform-paths plugin.
Full Explanation:
Sometimes it makes sense to run tsc in debug mode. For example in my case, we run tsc + start server in watch mode e.g. tsc-watch --compiler ttypescript/bin/tsc --onSuccess 'npm start'.
And if we run this in a debug session like on VSCode's debug terminal, it means we run both tsc and our sever in debug mode.
The problem is that when typescript throws errors on internal assertions it's also putting a "debugger;" statement right before it throws an error.
There's a block of code in this package (typescript-transform-paths) that wraps such TS errors in a try/catch. That causes our servers to get stuck (repeatedly) on a breakpoint when debugging in watch mode.
So, I've identified the root cause of these cases, and used an if condition to prevent the TS call altogether, instead of the try/catch.
I left the try/catch though just to be on safe side, cause there might be some other cases which I've missed.
What is the case that raises the TS error?
If a NodeObject is in position -1 you can't call getFullText on it.
TL;DR Allow running tsc in debug mode when using
typescript-transform-paths
plugin.Full Explanation: Sometimes it makes sense to run tsc in debug mode. For example in my case, we run tsc + start server in watch mode e.g.
tsc-watch --compiler ttypescript/bin/tsc --onSuccess 'npm start'
. And if we run this in a debug session like on VSCode's debug terminal, it means we run both tsc and our sever in debug mode.The problem is that when typescript throws errors on internal assertions it's also putting a "debugger;" statement right before it throws an error.
There's a block of code in this package (typescript-transform-paths) that wraps such TS errors in a try/catch. That causes our servers to get stuck (repeatedly) on a breakpoint when debugging in watch mode.
So, I've identified the root cause of these cases, and used an if condition to prevent the TS call altogether, instead of the try/catch. I left the try/catch though just to be on safe side, cause there might be some other cases which I've missed.
What is the case that raises the TS error? If a NodeObject is in position -1 you can't call getFullText on it.