Skip to content

Conversation

@hajjarjoseph
Copy link
Contributor

@hajjarjoseph hajjarjoseph commented Jan 3, 2026

Pull Request

Issue

Closes: #2848

Approach

Adds typesVersions and exports fields to package.json to expose type mappings for subpath imports (parse/node, parse/react-native).

  • typesVersions: Provides backward compatibility for older TypeScript versions and moduleResolution: "node"
  • exports: Modern approach for TypeScript 4.7+ with moduleResolution: "node16" or "bundler"

Tasks

  • Add tests (npm run test:types passes)

Summary by CodeRabbit

  • New Features
    • Added environment-specific module exports and corresponding type declarations for multiple runtime targets.
    • Improved TypeScript type resolution and package entry mappings for published builds.
    • No runtime behavior changes; changes affect packaging and type lookup only.

✏️ Tip: You can customize this high-level summary in your review settings.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Jan 3, 2026

🚀 Thanks for opening this pull request!

@coderabbitai
Copy link

coderabbitai bot commented Jan 3, 2026

📝 Walkthrough

Walkthrough

Added TypeScript type-resolution mappings and Node/React Native subpath exports to package.json. Introduces typesVersions for environment-specific declarations and an exports map exposing entry points (., ./node, ./react-native, ./react-native.js, ./weapp) plus passthroughs for ./dist/* and ./lib/*.

Changes

Cohort / File(s) Summary
Package manifest configuration
package.json
Added typesVersions mapping to route node and react-native imports to types/node.d.ts and types/react-native.d.ts. Added exports entries for ., ./node, ./react-native, ./react-native.js, ./weapp, and passthroughs for ./dist/* and ./lib/*, specifying types and default runtime files where applicable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • mtrezza

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description is complete with issue reference, approach explanation, and task completion status matching the template requirements.
Linked Issues check ✅ Passed The PR changes directly address issue #2848 by adding typesVersions and exports mappings for parse/node and parse/react-native subpath imports.
Out of Scope Changes check ✅ Passed All changes in package.json are scoped to exposing subpath type declarations, with no unrelated modifications present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: adding typesVersions and exports to fix TypeScript type resolution for subpaths (parse/node and parse/react-native).
✨ 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.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Jan 3, 2026

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3973eb and 3cdb1f6.

📒 Files selected for processing (1)
  • package.json
🔇 Additional comments (1)
package.json (1)

30-35: LGTM! Correct approach for TypeScript compatibility.

The typesVersions field correctly provides backward compatibility for TypeScript versions < 4.7 and moduleResolution: "node". The mappings for node and react-native subpaths align perfectly with the issue requirements.

@hajjarjoseph
Copy link
Contributor Author

@mtrezza Can you please check my pull request

@mtrezza
Copy link
Member

mtrezza commented Jan 5, 2026

@coderabbitai does this PR contain a breaking change?

@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.88%. Comparing base (a3973eb) to head (b3d3401).
⚠️ Report is 2 commits behind head on alpha.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha    #2849   +/-   ##
=======================================
  Coverage   99.88%   99.88%           
=======================================
  Files          64       64           
  Lines        6222     6222           
  Branches     1473     1473           
=======================================
  Hits         6215     6215           
  Misses          7        7           

☔ 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
Copy link

coderabbitai bot commented Jan 5, 2026

Tip

For best results, initiate chat on the files or code changes.

@mtrezza: This PR has the potential to be a breaking change, though mitigations are in place. Here's the analysis:

Why it could be breaking:

  1. The exports field is restrictive - Once added, Node.js and bundlers will ONLY allow imports that are explicitly listed. Any previously accessible files not in the exports map will become inaccessible.

  2. No explicit CJS/ESM conditions - The exports use "types" and "default" but don't specify "require" vs "import" conditions, which could affect module resolution in different environments.

  3. Limited subpath exports - Only specific paths are exposed:

    • ".", "./node", "./react-native", "./react-native.js", "./weapp"
    • Wildcards: "./dist/*" and "./lib/*"

Mitigations in place:

  • The wildcards "./dist/*" and "./lib/*" preserve access to distribution and library files
  • The commit message mentions "backward compatibility" indicating this was considered
  • Main entry points that should be commonly used are all mapped

Non-breaking aspect:

  • The typesVersions field is purely additive and fixes broken TypeScript type resolution

Recommendation:

To verify this isn't breaking, check if:

  1. Users import any internal files outside of dist/, lib/, or the explicitly listed subpaths
  2. The package works correctly in both CommonJS and ESM environments after this change
  3. All documented import patterns are covered in the exports map

If this package follows semantic versioning and there's any doubt, this should be released as a major version or thoroughly tested in a pre-release to avoid breaking existing users.

@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get the full package.json diff to see exact changes
git diff origin/alpha...HEAD -- package.json

# List all .js files in the root directory that could be entry points
fd -d 1 -e js -t f

# Check if there are any documented examples or tests showing import patterns
rg -n -C2 "from ['\"]parse/" --type=js --type=ts -g '!node_modules/**'

# Check for any documentation about imports
fd README -e md -x cat {}

Length of output: 9082


@mtrezza, this PR has a low risk of being a breaking change, but there is a small possibility in edge cases. Here's my analysis:

Analysis

Non-Breaking Aspects ✅

  1. typesVersions field: Purely additive for TypeScript type resolution - completely non-breaking.

  2. All documented entry points preserved:

    • parseindex.js
    • parse/nodenode.js
    • parse/react-native and parse/react-native.jsreact-native.js
    • parse/weappweapp.js
    • parse/dist/* → wildcard access to dist folder
    • parse/lib/* → wildcard access to lib folder
  3. README examples all work with the new exports field.

Potential Breaking Aspect ⚠️

The exports field can be breaking because:

  1. Strict enforcement: Node.js 12.7+ and modern bundlers strictly enforce exports - only paths explicitly listed are accessible. Any unlisted path becomes inaccessible.

  2. Edge cases that could break:

    • If users import undocumented root-level files directly (e.g., require('parse/babel-jest.js'))
    • If users import from directories other than dist/ or lib/ that aren't explicitly listed

Risk Assessment

Likelihood: Low because:

  • All documented, public APIs are preserved
  • The wildcards ./dist/* and ./lib/* cover most legitimate deep imports
  • Undocumented internal files shouldn't be part of the public API
  • This follows modern npm package best practices
  • Deploying to alpha branch first allows testing before release

Recommendation

This should not be considered a breaking change for semantic versioning purposes, as it:

  • Fixes a legitimate bug (TypeScript type resolution for subpaths)
  • Preserves all documented APIs
  • Only restricts access to undocumented internals (which is good practice)

However, you may want to mention in release notes that exports was added and encourage users to report any import issues during the alpha testing period.

@mtrezza
Copy link
Member

mtrezza commented Jan 5, 2026

@coderabbitai propose a commit message for non-breaking PR with fix: prefix

@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

Tip

For best results, initiate chat on the files or code changes.

@mtrezza: Here's a suggested commit message for this non-breaking fix:

fix: resolve TypeScript types for subpath imports (parse/node, parse/react-native)

Add `typesVersions` and `exports` fields to package.json to properly expose
TypeScript type declarations for subpath imports. This fixes the "Could not
find a declaration file" error when importing from `parse/node` or
`parse/react-native`.

- `typesVersions` provides backward compatibility for TS <4.7 and node moduleResolution
- `exports` supports modern TS 4.7+ with node16/bundler moduleResolution
- Includes wildcard exports for dist/* and lib/* to preserve access to distribution files

Fixes #2848

Alternative shorter version:

fix: resolve TypeScript types for parse/node and parse/react-native subpaths

Add typesVersions and exports fields to package.json to properly expose
type declarations for subpath imports, fixing type resolution errors.

Fixes #2848

Choose whichever level of detail you prefer. The first provides more context about the solution and compatibility, while the second is more concise.

@mtrezza mtrezza changed the title fix: Add typesVersions and exports for subpath TypeScript types resol… fix: TypeScript type resolution errors for parse/node and parse/react-native subpaths Jan 5, 2026
@mtrezza mtrezza changed the title fix: TypeScript type resolution errors for parse/node and parse/react-native subpaths fix: TypeScript type resolution errors for parse/node and parse/react-native subpaths Jan 5, 2026
@mtrezza mtrezza merged commit de684e5 into parse-community:alpha Jan 5, 2026
13 checks passed
parseplatformorg pushed a commit that referenced this pull request Jan 5, 2026
## [8.0.1-alpha.1](8.0.0...8.0.1-alpha.1) (2026-01-05)

### Bug Fixes

* TypeScript type resolution errors for `parse/node` and `parse/react-native` subpaths ([#2849](#2849)) ([de684e5](de684e5))
@parseplatformorg
Copy link
Contributor

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

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript types not resolved for parse/node subpath imports

3 participants