- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.4k
feat: Add TypeScript support #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add TypeScript support #595
Conversation
| I will reformat the title to use the proper commit message syntax. | 
| 🚀 Thanks for opening this pull request! | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
- Modify package.json scripts and dependencies - Update index.ts for TypeScript compatibility
ddcd572    to
    fc7e68a      
    Compare
  
    0ff84ec    to
    4a1ae28      
    Compare
  
    9524cf2    to
    fd27b5b      
    Compare
  
            
          
                package.json
              
                Outdated
          
        
      | "@semantic-release/release-notes-generator": "14.0.3", | ||
| "@types/jasmine": "^5.1.7", | ||
| "@types/node": "^22.14.1", | ||
| "@types/parse": "^3.0.9", | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parse started to bring its own types. Do we still need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parse types aren't working for some reason, I'll revert this commit until I know why it is not working
bc06b95    to
    9dc780b      
    Compare
  
    | Could you please resolve the conflicts? | 
# Conflicts: # package-lock.json # package.json
| WalkthroughThis update migrates the example package from JavaScript to TypeScript. It introduces TypeScript configuration files, updates ESLint and Jasmine configurations for TypeScript, and replaces or refactors JavaScript files with TypeScript equivalents. The build and start scripts are updated to use the TypeScript compiler and compiled output. Supporting files such as  Changes
 Sequence Diagram(s)sequenceDiagram
    participant User
    participant Docker
    participant App (TypeScript)
    participant Parse Server
    User->>Docker: Build image (uses Dockerfile, tsconfig.json, etc.)
    Docker->>App (TypeScript): Run compiled app (dist/index.js)
    App (TypeScript)->>Parse Server: Initialize with config, cloud code, schema
    User->>App (TypeScript): Send request (e.g., save TestObject)
    App (TypeScript)->>Parse Server: Process request, run cloud functions
    Parse Server-->>App (TypeScript): Return response
    App (TypeScript)-->>User: Return result
Assessment against linked issues
 ✨ Finishing Touches
 🪧 TipsChatThere are 3 ways to chat with CodeRabbit: 
 Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
 Other keywords and placeholders
 CodeRabbit Configuration File ( | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 11
♻️ Duplicate comments (2)
tsconfig.json (1)
2-14: Align TS config with Parse SDK conventions
As previously noted, the Parse JS SDK and Parse Server share a commontsconfig.jsonto enforce consistent compiler settings across repositories. If you intend to maintain uniform rulesets, consider reconciling this config with the upstream one.package.json (1)
53-53: Replace the range operator (^) with an exact version.Previous review requested removing range operators by using exact versions. The typescript-eslint dependency still has a range operator (^8.30.1).
#!/bin/bash # Check if other dependencies use range operators grep -E '"\^' package.json
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
- package-lock.jsonis excluded by- !**/package-lock.json
📒 Files selected for processing (22)
- .dockerignore(1 hunks)
- .env.example(1 hunks)
- .gitignore(1 hunks)
- Dockerfile(1 hunks)
- README.md(2 hunks)
- cloud/functions.ts(1 hunks)
- cloud/main.ts(1 hunks)
- cloud/schema.js(0 hunks)
- cloud/schema.ts(1 hunks)
- config.ts(1 hunks)
- eslint.config.js(0 hunks)
- eslint.config.mjs(1 hunks)
- index.ts(1 hunks)
- nodemon.json(1 hunks)
- package.json(2 hunks)
- public/test.html(2 hunks)
- spec/.eslintrc.json(0 hunks)
- spec/Tests.spec.ts(1 hunks)
- spec/support/jasmine.json(1 hunks)
- spec/tsconfig.json(1 hunks)
- tsconfig.json(1 hunks)
- types/parse-server.d.ts(1 hunks)
💤 Files with no reviewable changes (3)
- spec/.eslintrc.json
- cloud/schema.js
- eslint.config.js
🧰 Additional context used
🪛 LanguageTool
README.md
[style] ~88-~88: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... .eslintrc.json. * npm run lint-fix will attempt fix the linting of your cloud c...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~89-~89: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ts and index.ts. * npm run prettier will help improve the formatting and layout ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~90-~90: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... defined in .prettierrc. * npm test will run all tests * npm run coverage will...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
🪛 markdownlint-cli2 (0.17.2)
README.md
59-59: Fenced code blocks should be surrounded by blank lines
null
(MD031, blanks-around-fences)
59-59: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
68-68: Fenced code blocks should be surrounded by blank lines
null
(MD031, blanks-around-fences)
68-68: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
77-77: Lists should be surrounded by blank lines
null
(MD032, blanks-around-lists)
83-83: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
86-86: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
87-87: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
88-88: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
89-89: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
90-90: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
91-91: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
🔇 Additional comments (31)
index.ts (1)
9-9: Formatting: Insert blank line after imports
The blank line after theimport { config } from './config.js';statement improves readability by visually separating dependency imports from application logic.nodemon.json (3)
2-4: Ignore build output directory
Excludingdistfrom watch prevents Nodemon from restarting when compiled artifacts change, which is exactly the intended behavior in a TS build workflow.
5-5: Watch relevant file extensions
Theext: "json,ts,mjs,cjs,js"setting properly covers your source files and configs, ensuring Nodemon reacts to all changes you care about.
7-8: Ensuretsxruntime is installed
You’ve mapped.tsfiles to be executed viatsx. Please verify thattsxis declared in yourdevDependenciesso that Nodemon can invoke it without errors..gitignore (3)
33-33: Ignore ESLint cache file
Adding.eslintcacheprevents committing ESLint’s cache—good for keeping diffs clean.
34-36: Exclude compiled artifacts
Ignoring thedistdirectory aligns with your TypeScript build output configuration.
37-39: Handle environment files securely
Ignoring all.env*files while whitelisting.env.exampleis a best practice to protect sensitive variables.spec/support/jasmine.json (1)
3-4: LGTM: TypeScript test file patterns properly configuredThe configuration has been correctly updated to target TypeScript test files (
.ts) instead of JavaScript files, which aligns with the project's migration to TypeScript.cloud/main.ts (1)
4-4: LGTM: Empty export makes this a proper TypeScript moduleAdding
export {};is good practice to mark this file as a module in TypeScript, which affects its scope.spec/Tests.spec.ts (1)
16-16: LGTM: Using Parse.Error constant instead of magic numberGood improvement to use the
Parse.Error.OTHER_CAUSEconstant instead of a hardcoded error code. This enhances code readability and maintainability.spec/tsconfig.json (1)
1-10: LGTM: Well-configured TypeScript setup for testsThis is a well-structured TypeScript configuration for tests:
- Extends the root config for consistency
- Sets
noEmit: truewhich is appropriate for test files- Includes all TypeScript files in the spec directory
The configuration follows TypeScript best practices for test setups.
types/parse-server.d.ts (1)
1-2: Good first step for TypeScript compatibilityThis declaration file provides a minimal type definition for the Parse Server module, allowing TypeScript to recognize imports from this package without type errors. While this approach doesn't provide actual type checking, it's a pragmatic way to start the TypeScript migration.
For future improvements, consider:
- Creating more detailed type definitions
- Using DefinitelyTyped (@types/parse-server) if available
- Contributing types back to the original project
public/test.html (1)
71-71: Path update correctly reflects TypeScript migrationGood update to change the file extension from .js to .ts, ensuring the documentation correctly references the TypeScript cloud code file.
cloud/functions.ts (4)
2-3: Good use of TypeScript comment to acknowledge type limitationsThe
@ts-expect-errorcomment is appropriate here since thereq.logproperty exists in Parse Server but isn't included in the type definitions.For future improvements, consider adding this property to your custom type definitions.
9-10: Consistent error handling for TypeScript compatibilitySame technique applied consistently throughout the file.
15-15: Improved code clarity by using named constantGreat improvement to replace the magic number
9001with the named constantParse.Error.OTHER_CAUSE. This makes the code more readable and maintainable.
18-18: Required export for TypeScript modulesThe empty export statement is necessary for TypeScript to treat this file as a proper module. This is good practice when migrating to TypeScript.
.dockerignore (1)
1-39: Great addition of the .dockerignore file!This file properly excludes unnecessary files from the Docker build context, which will improve build performance and reduce image size. The organization by category (logs, runtime data, coverage, etc.) makes it easy to understand and maintain.
config.ts (2)
3-6: Improved database URI formattingThe reformatting of the database URI configuration improves readability.
6-6:✅ Verification successful
Modernized cloud code loading approach
Changing from a direct path to a dynamic import function is a good modernization that aligns with TypeScript practices and allows for asynchronous loading of cloud code.
🏁 Script executed:
#!/bin/bash # Check if the referenced main.js file exists or if it should be main.ts ls -la cloud/main.js cloud/main.ts 2>/dev/null || echo "Neither file exists" # Check for other modules using dynamic imports that might provide examples grep -r "import(" --include="*.ts" . | grep -v "config.ts"Length of output: 78031
Cloud import path is correct and ready to ship
The dynamic import of
./cloud/main.jsaligns with the compiled output (main.ts→main.js). This modernization is spot-on and no further changes are needed.README.md (3)
25-26: Properly updated table of contentsThe table of contents has been updated to include the new Docker Deployment section, maintaining document structure integrity.
77-80: Clear explanation of Docker volume benefitsThe explanation of Docker volume usage is clear and informative, helping users understand the benefits of the recommended approach.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
77-77: Lists should be surrounded by blank lines
null(MD032, blanks-around-lists)
95-95: Updated configuration file referenceThe configuration file reference has been properly updated from
config.jstoconfig.tsto reflect the TypeScript migration.Dockerfile (4)
1-13: Excellent multi-stage build implementationThe implementation of a multi-stage build process is an excellent improvement. This approach:
- Separates build-time dependencies from runtime dependencies
- Optimizes Docker layer caching by copying package.json files first
- Creates a smaller final image by only including necessary artifacts
These changes follow Docker best practices and will result in smaller, more efficient images.
19-23: Optimized final image with selective copyingSelectively copying only the required files from the builder stage is a good practice that minimizes the final image size.
24-24: Properly configured volumes for persistenceThe volume configuration aligns well with the Docker deployment instructions in the README, allowing for persistence of logs and runtime modification of cloud code.
28-28: Simplified startup commandThe startup command has been simplified to directly run the Node.js application rather than using npm scripts. This reduces an additional process layer and provides more direct control over the application process.
package.json (2)
10-22: LGTM! Good configuration for TypeScript migration.The changes to the package.json file correctly set up the project for TypeScript:
- Entry point updated to the compiled output
- Scripts updated to handle TypeScript files
- Build process properly configured with tsc
- Watch and preview scripts provide good developer experience
39-41: Appropriate type definitions added.Adding TypeScript type definitions for Jasmine, Node, and Parse is essential for TypeScript support.
eslint.config.mjs (2)
8-47: Well-structured TypeScript ESLint configuration.The ESLint configuration is comprehensive and well-designed for a TypeScript project:
- Properly extends recommended JS and TS configs
- Correctly sets up TypeScript parser with project references
- Provides appropriate globals including Parse
- Defines sensible rules for TypeScript development
- Ignores build artifacts and non-source directories
27-29: Good TypeScript-specific rule configuration.The configuration properly disables explicit return types (which can be too restrictive), warns on any usage (encouraging proper typing), and handles unused variables with appropriate exceptions for underscore-prefixed variables.
| @abubkr-hago I have closed some of the less important review feedbacks, as to not overwhelm you. You have already done the heavy lifting here. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
README.md (2)
54-75: Refine Markdown formatting around code fences
The new "Docker Deployment" section is valuable, but the fenced code blocks need a blank line before the opening triple-backticks for proper rendering (per MD031). Consider the following diff:diff --git a/README.md b/README.md index abcdef0..1234567 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,9 @@ -1. Create a `.env` file with your configuration variables. For example: -```env +1. Create a `.env` file with your configuration variables. For example: + +```env APP_ID=myAppId MASTER_KEY=myMasterKey DATABASE_URI=mongodb://localhost:27017/parse @@ -67,7 +69,9 @@ -2. Run Docker with the following command, mounting volumes as needed: -```bash +2. Run Docker with the following command, mounting volumes as needed: + +```bash docker build -t parse-server . docker run -p 1337:1337 --env-file .env \ -v $(pwd)/logs:/usr/src/parse/logs \
86-89: Standardize bullet style and tweak grammar in Helpful Scripts
The list in "Helpful Scripts" currently uses asterisks; the rest of the document uses hyphens for unordered lists. Also, thelint-fixdescription is missing "to". For consistency and clarity, apply:diff --git a/README.md b/README.md index 1234567..89abcde 100644 --- a/README.md +++ b/README.md @@ -86,4 +86,6 @@ -* `npm run lint` will check the linting of your cloud code, tests and `index.ts`, as defined in `.eslintrc.json`. -* `npm run lint-fix` will attempt fix the linting of your cloud code, tests and `index.ts`. -* `npm run prettier` will help improve the formatting and layout of your cloud code, tests and `index.ts`, as defined in `.prettierrc`. + - `npm run lint` will check the linting of your cloud code, tests, and `index.ts`, as defined in `.eslintrc.json`. + - `npm run lint-fix` will attempt to fix the linting of your cloud code, tests, and `index.ts`, as defined in `.eslintrc.json`. + - `npm run prettier` will help improve the formatting and layout of your cloud code, tests, and `index.ts`, as defined in `.prettierrc`.🧰 Tools
🪛 LanguageTool
[style] ~88-~88: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ....eslintrc.json. *npm run lint-fixwill attempt fix the linting of your cloud c...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[uncategorized] ~88-~88: Possible missing preposition found.
Context: ...son. *npm run lint-fix` will attempt fix the linting of your cloud code, tests a...(AI_HYDRA_LEO_MISSING_TO)
[style] ~89-~89: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ts andindex.ts. *npm run prettierwill help improve the formatting and layout ...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
🪛 markdownlint-cli2 (0.17.2)
86-86: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
87-87: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
88-88: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
89-89: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
- package-lock.jsonis excluded by- !**/package-lock.json
📒 Files selected for processing (6)
- Dockerfile(1 hunks)
- README.md(2 hunks)
- cloud/functions.ts(1 hunks)
- cloud/main.ts(1 hunks)
- package.json(2 hunks)
- tsconfig.json(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- cloud/main.ts
- cloud/functions.ts
- tsconfig.json
- Dockerfile
- package.json
🧰 Additional context used
🪛 LanguageTool
README.md
[style] ~88-~88: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... .eslintrc.json. * npm run lint-fix will attempt fix the linting of your cloud c...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[uncategorized] ~88-~88: Possible missing preposition found.
Context: ...son. * npm run lint-fix` will attempt fix the linting of your cloud code, tests a...
(AI_HYDRA_LEO_MISSING_TO)
[style] ~89-~89: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ts and index.ts. * npm run prettier will help improve the formatting and layout ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~90-~90: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... defined in .prettierrc. * npm test will run all tests * npm run coverage will...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
🪛 markdownlint-cli2 (0.17.2)
README.md
86-86: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
87-87: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
88-88: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
89-89: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
90-90: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
91-91: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
🔇 Additional comments (2)
README.md (2)
25-27: Verify TOC entry for Docker Deployment
The added- [Docker Deployment](#docker-deployment)entry should be indented under "Local Development" and its anchor slug must exactly match the heading text. On GitHub, the slug for## Docker Deploymentis#docker-deployment, so this looks correct.
95-95: Verify configuration file reference
The docs now point toconfig.ts. Please confirm that this file lives at the repository root (or update the path if it’s in a subdirectory such assrc/config.ts).
| Is this ready for merge? | 
| 
 LGTM | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done!
Closes #561
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Chores