Skip to content

fix: Parse.Object.createWithoutData doesn't preserve object subclass - #2907

Merged
mtrezza merged 5 commits into
parse-community:alphafrom
swittk:fix-createWithoutData
Feb 7, 2026
Merged

fix: Parse.Object.createWithoutData doesn't preserve object subclass#2907
mtrezza merged 5 commits into
parse-community:alphafrom
swittk:fix-createWithoutData

Conversation

@swittk

@swittk swittk commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Issue

This was originally already an issue with the original DefinitelyTyped typings, but with the new built-in typings the issue has expanded beyond the original scope.
Problem : createWithoutData calls on Parse.Object subclasses return object instances of that specific class. However, the current typings lose this connection and instead reverts to a generic Parse.Object type. Originally with the DefinitelyTyped typings this issue affected all user-defined classes, but at least Parse.User wasn't affected since it had its own separate typings. However, with our definition of ParseUser now extending from ParseObject, this version's Parse.User is also affected by this issue.

const user = Parse.User.createWithoutData('userId') // Originally would have types be Parse.User; right now it is Parse.Object

const myObj = MyClass.createWithoutData('objId') // We would expect that this is a `MyClass` instance, however the typings show as Parse.Object.

Approach

Added generic typing argument to createWithoutData. (this only affects TS typings, JS and usage wise it is still a single argument method)

Tasks

  • Add tests

Summary by CodeRabbit

  • Bug Fixes
    • Improved TypeScript typings so factory calls on subclass types now return the correct subclass type, enhancing type safety, reducing type errors, and improving IDE autocomplete and developer ergonomics.

@parse-github-assistant

parse-github-assistant Bot commented Feb 7, 2026

Copy link
Copy Markdown

🚀 Thanks for opening this pull request!

@parseplatformorg

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

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Changed the static ParseObject.createWithoutData signature to a generic form using a this-type parameter so calls return the specific subclass type; corresponding typings and type-test declarations were updated.

Changes

Cohort / File(s) Summary
Core implementation & types
src/ParseObject.ts, types/ParseObject.d.ts
Replaced static createWithoutData(id: string): ParseObject with static createWithoutData<T extends ParseObject>(this: new (...args: any[]) => T, id: string): T to preserve subclass return types.
Type test declarations
types/tests.ts
Added/updated createWithoutData static signatures for Game, GameScore, and Parse.User to reflect the new typed return; removed a trailing newline in a test file (formatting).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 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
Description check ✅ Passed The description includes the required Issue section with problem context, the Approach section explaining the solution, and indicates tests were added. However, the Issue section lacks an explicit link/reference number to close.
Title check ✅ Passed The PR title accurately describes the main change: fixing the TypeScript typing of createWithoutData to preserve object subclass types instead of returning a generic ParseObject.

✏️ 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.

@swittk swittk changed the title Fix: createWithoutData doesn't preserve the class of the invoking object. fix: createWithoutData doesn't preserve the class of the invoking object. Feb 7, 2026
@parse-github-assistant

Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title fix: createWithoutData doesn't preserve the class of the invoking object. fix: CreateWithoutData doesn't preserve the class of the invoking object. Feb 7, 2026
@codecov

codecov Bot commented Feb 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (89fdb07) to head (8902c48).
⚠️ Report is 24 commits behind head on alpha.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@types/tests.ts`:
- Around line 45-52: Fix the typo in the test comment by changing
"createWitoutData" to "createWithoutData" so the comment matches the actual
method name used in the assertions; update the comment that precedes
Game.createWithoutData / GameScore.createWithoutData /
Parse.User.createWithoutData to use the correct spelling "createWithoutData".

Comment thread types/tests.ts Outdated
@mtrezza mtrezza changed the title fix: CreateWithoutData doesn't preserve the class of the invoking object. fix: Parse.Object.createWithoutData doesn't preserve class of invoking object Feb 7, 2026
@mtrezza mtrezza changed the title fix: Parse.Object.createWithoutData doesn't preserve class of invoking object fix: Parse.Object.createWithoutData doesn't preserve class type of invoking object Feb 7, 2026
@mtrezza mtrezza changed the title fix: Parse.Object.createWithoutData doesn't preserve class type of invoking object fix: Parse.Object.createWithoutData doesn't preserve instance type of object class Feb 7, 2026
@mtrezza mtrezza changed the title fix: Parse.Object.createWithoutData doesn't preserve instance type of object class fix: Parse.Object.createWithoutData doesn't preserve object subclass Feb 7, 2026
@mtrezza
mtrezza merged commit 01dc94d 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.2](8.1.1-alpha.1...8.1.1-alpha.2) (2026-02-07)

### Bug Fixes

* `Parse.Object.createWithoutData` doesn't preserve object subclass ([#2907](#2907)) ([01dc94d](01dc94d))
@parseplatformorg

Copy link
Copy Markdown
Contributor

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

@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