feat(Resolver): allow optional resolveContext on resolve()#536
Merged
alexander-akait merged 6 commits intomainfrom Apr 17, 2026
Merged
feat(Resolver): allow optional resolveContext on resolve()#536alexander-akait merged 6 commits intomainfrom
alexander-akait merged 6 commits intomainfrom
Conversation
Match resolveSync/resolvePromise by letting callers invoke Resolver#resolve without a resolveContext. A callback passed in the 4th position is now treated as the callback, and missing/null resolveContext falls back to an empty object. Tightens argument validation with consistent typeof/null checks and throws a TypeError when the callback is missing.
Expose the two public call signatures as @overload JSDoc blocks so the generated TypeScript declarations emit a real overload set (callback-in-fourth-position vs. full resolveContext + callback) instead of a union parameter.
…Promise When the first argument is a string, treat it as the path and shift the remaining arguments. This matches the existing behavior of the top-level resolve/resolveSync/resolvePromise helpers in lib/index.js. Additional JSDoc @overload blocks expose the four (resolve) / two (resolveSync, resolvePromise) valid call signatures, so the generated TypeScript declarations reflect the new optional context.
|
|
| Name | Type |
|---|---|
| enhanced-resolve | Minor |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #536 +/- ##
==========================================
- Coverage 96.58% 96.45% -0.14%
==========================================
Files 50 50
Lines 2665 2678 +13
Branches 812 814 +2
==========================================
+ Hits 2574 2583 +9
- Misses 76 80 +4
Partials 15 15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
resolveSync and resolvePromise now delegate directly to resolve() without pre-shifting arguments. resolve() handles both call styles: the user-facing 3/4-arg form (callback in the former resolveContext or request slot) and the 5-arg delegate form where the callback is already in place.
Reorder `!x || typeof x !== "object"` so the cheap falsy check short-circuits before the typeof, and add short comments explaining why the shift block and the 4-arg fall-through exist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Match resolveSync/resolvePromise by letting callers invoke
Resolver#resolve without a resolveContext. A callback passed in the
4th position is now treated as the callback, and missing/null
resolveContext falls back to an empty object. Tightens argument
validation with consistent typeof/null checks and throws a TypeError
when the callback is missing.