runTsc breaks in Typescript v5.7 when providing extraSupportedExtensions
#251
Labels
bug
Something isn't working
extraSupportedExtensions
#251
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 theextraSupportedExtensions
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 torunTsc
may be a shim that pulls in the main code. It's no longer safe to assume like we do in transformTscContent that thetsc
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
require
d at the end of the file at thetscPath
if it's missing the content that we expect, but that could be finicky. I'm open to suggestions.The text was updated successfully, but these errors were encountered: