Skip to content

fix: Parse.Query.and/or/nor loosing custom class types - #2903

Merged
mtrezza merged 2 commits into
parse-community:alphafrom
swittk:fix-parsequery-types
Feb 7, 2026
Merged

fix: Parse.Query.and/or/nor loosing custom class types#2903
mtrezza merged 2 commits into
parse-community:alphafrom
swittk:fix-parsequery-types

Conversation

@swittk

@swittk swittk commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Issue

Parse.Query in the old DefinitelyTyped typings used to allow for strict typings when we're doing and/or/nor operations.

Example failing case:

class MyClass extends Parse.Object<{ a: number }> {};
const q1 = new Parse.Query(MyClass).equalTo('a', 2);
const q2 = new Parse.Query(MyClass).equalTo('a', 3);
/*
In the old DefinitelyTyped typings; this would be preserved as Parse.Query<MyClass>
However, with our current typings, this loses the class typing, making it go back to ParseQuery<ParseObject<Attributes>> 
*/
const orQ = Parse.Query.or(q1, q2);

Approach

Allow for generic ParseObject subclass types to be captured & propagated in ParseQuery and/or/nor.

Tasks

  • Add tests

Summary by CodeRabbit

  • Refactor

    • Improved type safety for query combination operations, ensuring combined queries maintain accurate type information.
  • Tests

    • Added tests to verify type preservation when combining queries.

@parse-github-assistant

parse-github-assistant Bot commented Feb 6, 2026

Copy link
Copy Markdown

🚀 Thanks for opening this pull request!

@parseplatformorg

parseplatformorg commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Feb 6, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR introduces generic type parameters to the static or, and, and nor methods in ParseQuery, ensuring that combining typed queries of a specific ParseObject subclass returns a typed query result of that same class. This improves type safety for query composition.

Changes

Cohort / File(s) Summary
Generic Type Parameters for Query Combinators
src/ParseQuery.ts, types/ParseQuery.d.ts
Added generic type parameter T extends ParseObject to or, and, and nor static methods, updating signatures to accept ParseQuery<T>[] and return ParseQuery<T> instead of untyped ParseQuery.
Type Verification Tests
types/tests.ts
Added test cases verifying that or, and, and nor preserve the class type when combining queries, confirming return types as ParseQuery<MyClass> for a custom ParseObject subclass.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • mtrezza
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the issue with a code example, explains the approach to fix it, and confirms tests were added. However, it does not include a link to a related issue as required by the template. Add a link to the related GitHub issue in the 'Closes:' field to complete the description template requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing TypeScript generic type preservation in Parse.Query.and/or/nor methods when combining queries.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Feb 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b4156ac) to head (0c982b9).
⚠️ Report is 25 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff            @@
##             alpha     #2903   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           64        64           
  Lines         6235      6235           
  Branches      1493      1481   -12     
=========================================
  Hits          6235      6235           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mtrezza mtrezza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this ready for merge?

@mtrezza mtrezza changed the title fix: ParseQuery and/or/nor losing typings fix: Parse.Query.and/or/nor loosing custom types Feb 7, 2026
@mtrezza mtrezza changed the title fix: Parse.Query.and/or/nor loosing custom types fix: Parse.Query.and/or/nor loosing custom class types Feb 7, 2026
@swittk

swittk commented Feb 7, 2026

Copy link
Copy Markdown
Contributor Author

I think so, yes.

@mtrezza
mtrezza merged commit 89fdb07 into parse-community:alpha Feb 7, 2026
13 checks passed
parseplatformorg pushed a commit that referenced this pull request Feb 7, 2026
## [8.1.1-alpha.1](8.1.0...8.1.1-alpha.1) (2026-02-07)

### Bug Fixes

* `Parse.Query.and/or/nor` loosing custom class types ([#2903](#2903)) ([89fdb07](89fdb07))
@parseplatformorg

Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 8.1.1-alpha.1

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Feb 7, 2026
parseplatformorg pushed a commit that referenced this pull request Feb 20, 2026
# [8.2.0](8.1.0...8.2.0) (2026-02-20)

### Bug Fixes

* `Parse.Object.createWithoutData` doesn't preserve object subclass ([#2907](#2907)) ([01dc94d](01dc94d))
* `Parse.Query.and/or/nor` loosing custom class types ([#2903](#2903)) ([89fdb07](89fdb07))
* `Parse.serverURL` not accessible via global `Parse` scope ([#2917](#2917)) ([4e78681](4e78681))
* Cloud trigger type errors for void returns and subclass constructors ([#2904](#2904)) ([de9f56d](de9f56d))
* Missing or incorrect type exports ([#2909](#2909)) ([3caa4ec](3caa4ec))
* Type error in `Parse.Query.equalTo` when matching optional array ([#2901](#2901)) ([8c96da9](8c96da9))

### Features

* Add request header `X-Parse-Upload-Mode` to identify file upload as binary data via `Buffer`, `Readable`, `ReadableStream` ([#2927](#2927)) ([a66bb06](a66bb06))
* Add support for file upload as binary data via `Buffer`, `Readable`, `ReadableStream` ([#2925](#2925)) ([e42caf6](e42caf6))
@parseplatformorg

Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 8.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released Released as stable version state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants