Skip to content
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

fix: Fix option parsing and types #258

Merged
merged 1 commit into from
Jan 6, 2025
Merged

fix: Fix option parsing and types #258

merged 1 commit into from
Jan 6, 2025

Conversation

Gudahtt
Copy link
Owner

@Gudahtt Gudahtt commented Jan 6, 2025

The option types wrongly declared jsonSortOrder as a required option, resulting in a type mismatch. If no jsonSortOrder was specified, it would be typed as Record<..> despite having the value null. This had no runtime functional impact but it was still wrong and confusing.

The option parsing has been updated to better preserve type safety, and the types have been updated to differentiate pre-processed options, processed options, and options with defaults applied at runtime.

This can be omitted from the changelog because the fixed types are not exported.

@Gudahtt Gudahtt force-pushed the fix-option-types branch 2 times, most recently from cadeec5 to 3d02668 Compare January 6, 2025 14:45
The option types wrongly declared `jsonSortOrder` as a required option,
resulting in a type mismatch. If no `jsonSortOrder` was specified, it
would be typed as `Record<..>` despite having the value `null`. This
had no runtime functional impact but it was still wrong and confusing.

The option parsing has been updated to better preserve type safety, and
the types have been updated to differentiate pre-processed options,
processed options, and options with defaults applied at runtime.
if (jsonSortOrder) {
sortCompareFunction = createSortCompareFunction(jsonSortOrder);
}
const sortCompareFunction = createSortCompareFunction(jsonSortOrder);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default option of {} is now applied before this point, so we don't need to consider where jsonSortOrder is unset anymore. {} is equivalent to lexical sort.

@Gudahtt Gudahtt merged commit 5af8bd1 into main Jan 6, 2025
12 checks passed
@Gudahtt Gudahtt deleted the fix-option-types branch January 6, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant