UnknownCoder404 / Cubing-competition-server

Nodejs server for cubing competition website
0 stars 0 forks source link

Typescript #1

Open UnknownCoder404 opened 3 weeks ago

UnknownCoder404 commented 3 weeks ago

Feature Request: Convert JavaScript Codebase to TypeScript

Description:

Currently, our application is written entirely in JavaScript. To improve code maintainability, scalability, and developer experience, we need to convert the codebase to TypeScript. This conversion will introduce static typing, allowing for better error detection during development and improved code clarity. Since we are using Bun, which has native TypeScript support, this transition should be relatively smooth.

Motivation:

Proposed Implementation Plan:

We propose a phased approach to the TypeScript conversion:

  1. Initial Setup: Configure Bun's TypeScript settings (if any are required). Add a tsconfig.json file with appropriate compiler options (e.g., strict mode for maximum type safety).
  2. Gradual Conversion: Start by converting core modules or files with well-defined interfaces. Focus on converting smaller, less complex modules first to gain momentum and experience.
  3. Testing and Validation: Thoroughly test each converted module to ensure that existing functionality remains intact. Update any relevant tests to incorporate type checking.
  4. Continuous Integration: Integrate TypeScript compilation into our CI/CD pipeline to enforce type checking and prevent regressions.
  5. Documentation Updates: Update any existing documentation to reflect the changes introduced by TypeScript.
  6. Ongoing Maintenance: Continuously monitor and address any TypeScript-related issues that arise during development.

Potential Challenges:

Alternatives Considered:

Staying with JavaScript was considered. However, the long-term benefits of TypeScript outweigh the initial cost of conversion, especially given Bun's native support.

Discussion:

We welcome any feedback or suggestions regarding the proposed plan. Please share your thoughts and concerns in the comments below.

UnknownCoder404 commented 3 weeks ago

On the way of doing this, turn any commonjs modules into es modules:

Turn

const User = require("../Models/user");

into:

import User from "../Models/user"