-
-
Notifications
You must be signed in to change notification settings - Fork 16
fix: correct the return type of applyInlineConfig
#162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fasttime
merged 6 commits into
main
from
fix-correct-the-return-type-of-applyinlineconfig
Oct 21, 2025
Merged
fix: correct the return type of applyInlineConfig
#162
fasttime
merged 6 commits into
main
from
fix-correct-the-return-type-of-applyinlineconfig
Oct 21, 2025
Conversation
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
lumirlumir
commented
Oct 2, 2025
This was referenced Oct 2, 2025
9 tasks
Member
Author
|
Pending until humanwhocodes/momoa#197 is merged. |
…t-the-return-type-of-applyinlineconfig
Member
Author
fasttime
approved these changes
Oct 21, 2025
Member
fasttime
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
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.
Prerequisites checklist
What is the purpose of this pull request?
Which language are you using?
JSONC and JSON5
What did you do?
I expected the return type of
applyInlineConfig().configs— specificallyloc.startandloc.end— to include anoffsetproperty, but they don't.What did you expect to happen?
I expect the types of
loc.startandloc.endto include anoffsetproperty.Link to minimal reproducible Example
If you run the code above, you'll see that
jsonSourceCode.applyInlineConfig().configs[0].loc.startandjsonSourceCode.applyInlineConfig().configs[0].loc.endinclude anoffsetproperty. However, the return type doesn't reflect thatoffsetproperty.# Output { start: { line: 1, column: 1, offset: 0 }, end: { line: 1, column: 45, offset: 44 } }What changes did you make? (Give an overview)
Looking at the origin of the
locproperty returned byapplyInlineConfig, you'll find that it directly uses thecomment.loc.json/src/languages/json-source-code.js
Line 273 in b1b5743
The
comment.locproperty uses theJSONSyntaxElement['loc'](LocationRange) type from@humanwhocodes/momoaas shown below, so technically it doesn’t match theSourceLocationtype.JSONSyntaxElement['loc'](LocationRange)SourceLocationTo provide a more accurate return type, I've replaced the
SourceLocationtype with theJSONSyntaxElement['loc'](LocationRange) type from@humanwhocodes/momoa.Related Issues
Ref: eslint/markdown#548, eslint/css#281
Is there anything you'd like reviewers to focus on?
N/A