Fix porting bug in resolveAutomaticTypeDirectives#2562
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a porting bug in resolveAutomaticTypeDirectives where the wrong resolution mode was being used. The original TypeScript code passes undefined as the mode parameter, which should translate to ResolutionModeNone in Go, but the port incorrectly used ModuleKindNodeNext.
Changes:
- Fixed the resolution mode for automatic type directives from
ModuleKindNodeNexttoResolutionModeNone - Added explanatory comments describing the behavior for both node16/nodenext and bundler module resolution
- Added a comprehensive test case to verify the fix works correctly with bundler module resolution
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
internal/compiler/fileloader.go |
Corrected the resolution mode from ModuleKindNodeNext to ResolutionModeNone and added explanatory comments |
testdata/tests/cases/compiler/automaticTypeDirectiveResolutionBundler.ts |
New test demonstrating that automatic type directives resolve with the correct condition under bundler resolution |
testdata/baselines/reference/compiler/automaticTypeDirectiveResolutionBundler.types |
Expected type baseline showing correct resolution to esm.d.mts |
testdata/baselines/reference/compiler/automaticTypeDirectiveResolutionBundler.trace.json |
Trace baseline confirming the 'import' condition is matched during resolution |
testdata/baselines/reference/compiler/automaticTypeDirectiveResolutionBundler.symbols |
Symbol baseline showing correct symbol resolution |
andrewbranch
left a comment
There was a problem hiding this comment.
This seems good but why didn't it delete any diffs?
|
I'm not sure. The relationship between |
|
Forcing this into Strada with casts nets these two failures: So we don't actually have any tests for this. Yay! |
Fixes #2418
The original TS says:
Our version of
undefinedmode isResolutionModeNone.This test is goofy, but the best I could come up with to show that there's a difference (check the second commit)
For #2418, #2361 actually fixed most of the issues. This fixes the rest, except for:
And these are three cases of deduplicated files that tsc did not properly deduplicate (but my PR seemingly does), a case I believe Sheetal noted.