Skip to content

fix: Type error in Parse.Query.equalTo when matching optional array - #2901

Merged
mtrezza merged 7 commits into
parse-community:alphafrom
swittk:fix-query-equalto
Feb 11, 2026
Merged

mtrezza merged 7 commits into
parse-community:alphafrom
swittk:fix-query-equalto

Conversation

@swittk

@swittk swittk commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Issue

For optional arrays (e.g. field?: ClassName[] ), the equalTo function has always shown a type error when we try to match, when the underlying runtime has always worked (Parse supports matching of "array contains element" natively). This only happens when the array is optional; required arrays types already allow element matching

Example

class MyClass extends Parse.Object<{ myArrayField?: Parse.User[]  }> {}

const u = new Parse.User();
/*
this will error out with this error :
Argument of type 'User<Attributes>' is not assignable to parameter of type 'User<Attributes>[]'.
  Type 'User<Attributes>' is missing the following properties from type 'User<Attributes>[]': length, pop, push, concat, and 29 more.ts(2345)
*/
const q = new Parse.Query(MyClass).equalTo('myArrayField', u);

Closes: FILL_THIS_OUT

Approach

NonNullable assertion in equalTo/notEqualTo allows for type-level check to ignore undefined when deciding whether the field is a ParseObject or an array, allowing for normal "array contains element" type inference same as for required arrays, things like { fieldName: MyClass[] }.

Tasks

  • Add tests

Summary by CodeRabbit

  • Improvements

    • Improved type resolution for equalTo / notEqualTo to ignore undefined when inferring pointer vs. array-element values, tightening type safety for queries on nullable/optional attributes.
  • Tests

    • Added tests exercising queries against newly declared optional array attributes (object and string arrays), validating accepted element matches and rejecting invalid element types.

@parse-github-assistant

parse-github-assistant Bot commented Feb 5, 2026 •

Copy link
Copy Markdown

🚀 Thanks for opening this pull request!

❌ Please fill out all fields with a placeholder FILL_THIS_OUT. If a field does not apply to the pull request, fill in n/a or delete the line.

@parseplatformorg

parseplatformorg commented Feb 5, 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 5, 2026 •

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Type-level updates to ParseQuery methods: equalTo and notEqualTo now use NonNullable<T['attributes'][K]> when inferring Pointer/array element types. Tests add two optional array attributes and expand type-level query tests. No runtime behavior changes.

Changes

Cohort / File(s) Summary
ParseQuery type changes
types/ParseQuery.d.ts, src/ParseQuery.ts
Updated equalTo and notEqualTo signatures to use NonNullable<T['attributes'][K]> in the conditional unions that infer ParseObject (Pointer) or array element types; purely type-level change affecting inference when attributes may be optional/nullable.
Tests — new optional array attributes
types/tests.ts
Added attribute5?: AnotherSubClass[] and attribute6?: string[] to MySubClass attributes and expanded tests to validate equalTo usage for single-element and full-array matches and to assert type-safety (including negative cases) for invalid element types.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • mtrezza
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing a TypeScript type error in Parse.Query.equalTo when matching optional array fields.
Description check ✅ Passed The description is mostly complete with issue context, approach explanation, and completed tasks; however, the 'Closes' field was left empty (FILL_THIS_OUT template text).

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

✨ Finishing touches
🧪 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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Feb 5, 2026
@codecov

codecov Bot commented Feb 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ae2787b) to head (259b76d).
⚠️ Report is 13 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff            @@
##             alpha     #2901   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           64        64           
  Lines         6235      6235           
  Branches      1481      1477    -4     
=========================================
  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.

@dplewis

dplewis commented Feb 5, 2026

Copy link
Copy Markdown
Member

@swittk That's a name I haven't seen in a while. Nice catch!

@swittk

swittk commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi! Nice to contribute something back once in a while 😅, life's been pretty busy but this issue's been irking me for a long time, so hopefully this helps someone else too.
I.. can't seem to find the button to edit the title of the PR though. (Edit : NVM, found it in the "classic experience" view)

@swittk swittk changed the title Allow equalTo to match for optional arrays fix : Allow equalTo to match for optional arrays Feb 5, 2026
@swittk swittk changed the title fix : Allow equalTo to match for optional arrays fix: Allow equalTo to match for optional arrays Feb 5, 2026
@dplewis

dplewis commented Feb 5, 2026 •

Copy link
Copy Markdown
Member

so hopefully this helps someone else too.

The goal of OSS and contributing

found it in the "classic experience" view

I couldn't find it either or I would have done it for you

@dplewis

dplewis commented Feb 5, 2026 •

Copy link
Copy Markdown
Member

@swittk Are you just adding test cases? I see you added NonNullable and removed it, I assume nullable was the default aka optional.

@swittk

swittk commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author

Apologies, I forgot to commit the actual source file so when I ran to regenerate the types it simply disappeared. Should be fixed now.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Feb 5, 2026
@mtrezza mtrezza changed the title fix: Allow equalTo to match for optional arrays fix: Allow Parse.Query.equalTo to match for optional arrays Feb 10, 2026
@mtrezza mtrezza changed the title fix: Allow Parse.Query.equalTo to match for optional arrays fix: Type error in Parse.Query.equalTo when matching optional arrays Feb 10, 2026
@mtrezza mtrezza changed the title fix: Type error in Parse.Query.equalTo when matching optional arrays fix: Type error in Parse.Query.equalTo when matching optional array Feb 10, 2026
@mtrezza

mtrezza commented Feb 11, 2026

Copy link
Copy Markdown
Member

Is this ready for merge?

@swittk

swittk commented Feb 11, 2026

Copy link
Copy Markdown
Contributor Author

Yes, I think so.

@mtrezza
mtrezza merged commit 8c96da9 into parse-community:alpha Feb 11, 2026
13 checks passed
parseplatformorg pushed a commit that referenced this pull request Feb 11, 2026
## [8.1.1-alpha.5](8.1.1-alpha.4...8.1.1-alpha.5) (2026-02-11)

### Bug Fixes

* Type error in `Parse.Query.equalTo` when matching optional array ([#2901](#2901)) ([8c96da9](8c96da9))
@parseplatformorg

Copy link
Copy Markdown
Contributor

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

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Feb 11, 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.

4 participants