When using the runTsc function from the @volar/typescript npm package, the code will break if the user has Typescript v5.7 or higher and they have a non-empty array provided on the extraSupportedExtensions option (see this issue for an example).
This happens because in Typescript v5.7, they start making use of a shim in order enable Node.js/v8 compile caching. This means that the tscPath provided to runTsc may be a shim that pulls in the main code. It's no longer safe to assume like we do in transformTscContent that the tsc argument includes any of the code we want to update.
I spent quite a while digging through to code to figure out the exact issue. I'm happy to submit a PR to fix the issue, but I thought it might be best to submit an issue first in case we wanted to discuss what the ideal solution would look before I start messing with code.
The easiest way I can see to solve it off the top of my head would be to add a check for the file that gets required at the end of the file at the tscPath if it's missing the content that we expect, but that could be finicky. I'm open to suggestions.
When using the runTsc function from the
@volar/typescriptnpm package, the code will break if the user has Typescript v5.7 or higher and they have a non-empty array provided on theextraSupportedExtensionsoption (see this issue for an example).This happens because in Typescript v5.7, they start making use of a shim in order enable Node.js/v8 compile caching. This means that the
tscPathprovided torunTscmay be a shim that pulls in the main code. It's no longer safe to assume like we do in transformTscContent that thetscargument includes any of the code we want to update.I spent quite a while digging through to code to figure out the exact issue. I'm happy to submit a PR to fix the issue, but I thought it might be best to submit an issue first in case we wanted to discuss what the ideal solution would look before I start messing with code.
The easiest way I can see to solve it off the top of my head would be to add a check for the file that gets
required at the end of the file at thetscPathif it's missing the content that we expect, but that could be finicky. I'm open to suggestions.