fix: prevent error when the script tag is removed in nodenext projects #2635
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of #2538. The problem is becuase we're patching
impliedNodeFormat
in module resolution. When we can't even parse the script tag the module resolution won't happen and theimpliedNodeFormat
won't be patched. This causes TypeScript to try to clear the old source file and trigger the Debug.assert.I also found another situation that would trigger the same
Debug.assert
but I haven't found a way to fix it. Might have to open an issue on TypeScript for that one. At least we can get this easier one fixed.I also can't figure out the exact condition that triggers #2534 (comment). From the typescript source code, it makes no sense this would happen. The error fixed in this PR might cause the document registry to update but not the language service. So maybe #2534 (comment) is caused by the weird state after the error but I still can't find the exact situation.