parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

TypeScript: "Cannot find name 'Parse'" when using Parse.Cloud in cloud code

Open tiavina-mika opened this issue 1 month ago • 2 comments

New Issue Checklist

Issue Description

TypeScript does not recognize the global Parse object in cloud code, resulting in the error: Cannot find name 'Parse' when referencing Parse.Cloud. This happens even after installing the parse package and using the recommended import patterns. The Parse object is available at runtime, but TypeScript does not recognize it, making it difficult to write type-safe cloud code.

Steps to reproduce

  1. Clone the repo: https://github.com/tiavina-mika/parse-server-8-ts-issue
  2. Run npm install
  3. Open src/cloud/main.ts in VS Code.
  4. You will see a TypeScript error on any usage of Parse (e.g., Parse.Cloud.beforeSave).

Actual Outcome

TypeScript compilation fails with: Cannot find name 'Parse'

Expected Outcome

TypeScript should recognize the global Parse object and allow type-safe cloud code development.

Environment

Server

  • Parse Server version: 8.2.5
  • Operating system: Windows
  • Local or remote host: Local

Database

  • System: MongoDB
  • Database version: v4.0.6
  • Local or remote host: local

Logs

cloud/main.ts:XX:XX - error TS2304: Cannot find name 'Parse'.

tiavina-mika avatar Oct 30 '25 06:10 tiavina-mika

🚀 Thanks for opening this issue!

ℹ️ You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

Solution found:

To fix the TypeScript error with the global Parse object in cloud code, create a file named global-parse.d.ts and add:

declare global {
  // eslint-disable-next-line no-var
  var Parse: typeof import('parse/node');
}
export {};

Now, there are no more TypeScript errors.

You can find the working solution here: https://github.com/tiavina-mika/parse-server-8-ts-issue/tree/upgrade/8.2.5

NOTE: It only works if you use: "@types/parse": "3.0.9"

tiavina-mika avatar Oct 31 '25 06:10 tiavina-mika