Skip to content

Conversation

@vkarpov15
Copy link
Collaborator

Summary

Right now FilterQuery types resolve to any for any query properties, which means query operators like $gt etc don't show up in intellisense (re: #15406). Making this change would break #14473, but that's an easy workaround - just add an as.

Bring back the changes reverted by #14510 - I think the benefit of autocomplete outweighs the friction of adding an as when you're using a pattern that you're not supposed to in TypeScript (at least according to https://stackoverflow.com/questions/56505560/how-to-fix-ts2322-could-be-instantiated-with-a-different-subtype-of-constraint).

Examples

@vkarpov15 vkarpov15 added this to the 9.0 milestone May 13, 2025
@vkarpov15 vkarpov15 changed the base branch from master to 9.0 May 13, 2025 19:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a breaking change that updates FilterQuery types in TypeScript so that query properties no longer default to any, improving IntelliSense support for query operators.

  • Updated type tests in test/types/queries.test.ts to include explicit cast usage for FilterQuery.
  • Added a workaround cast in the findById function (gh14510) to handle stricter typing.
  • Minor updates in test/query.test.js to support the overall changes.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
test/types/queries.test.ts Added explicit casts for FilterQuery in type tests and gh14510 function update
test/query.test.js Minor test update for findById behavior confirmation

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

LGTM

@hasezoey hasezoey added backwards-breaking typescript Types or Types-test related issue / Pull Request labels May 14, 2025
@vkarpov15 vkarpov15 merged commit a10dd67 into 9.0 May 14, 2025
35 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-14506 branch May 14, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards-breaking typescript Types or Types-test related issue / Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants