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: add string type to gt/lt/gte/lte type definitions #2704

Merged
merged 1 commit into from
Jul 12, 2024
Merged

fix: add string type to gt/lt/gte/lte type definitions #2704

merged 1 commit into from
Jul 12, 2024

Conversation

damieng
Copy link
Contributor

@damieng damieng commented Jul 11, 2024

πŸ”— Linked issue

#437

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The $gte, $gt, $lt, $lte operators are defined in the Typescript as only taking a number. This is in fact incorrect as they map to the standard JavaScript >=, >, <, <= operators which can handle any more types and as the test coverage shows they work perfect with strings.

This fix is needed as anyone trying to use these operators with a string - such as in a common case as filtering by alpha ranges or even a sort-formatted date string - will receive Typescript errors leading them to think this is not the way to do it.

This adds the string type to those operators, adds test coverage to prove they work and importantly adds an example to the filtering docs showing how to use the string filtering to sort by a date which is a common situation and one the linked ticket went into.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Copy link
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

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

Thanks

@farnabaz farnabaz merged commit 233533d into nuxt:main Jul 12, 2024
2 checks passed
@damieng damieng deleted the fix-typescript-defs-for-ltgt-ops branch July 12, 2024 16:58
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.

2 participants