elersong / fireorm24

ORM for Firebase Firestore 🔥 updated for 2024
MIT License
1 stars 0 forks source link

Enable Stricter TS Rules #20

Open elersong opened 3 months ago

elersong commented 3 months ago

Description

To improve code quality and catch potential issues early, Fireorm should enable stricter TypeScript rules. The goal is to gradually migrate the codebase to comply with strict: true settings in tsconfig.json.

Steps to Reproduce

  1. Enable strict TypeScript rules in tsconfig.json.
  2. Attempt to compile the Fireorm codebase.
  3. Identify and fix TypeScript errors that arise from stricter type checking.

Expected Behavior

The Fireorm codebase should compile without errors under strict TypeScript rules, ensuring better type safety and code quality.

Actual Behavior

The current codebase may not compile under strict TypeScript rules due to various type-related issues.

Acceptance Criteria

Additional Context

Proposed Plan

  1. Incremental Approach:

    • Migrate to strict TypeScript rules incrementally, focusing on one folder or file at a time.
    • Use an inner tsconfig.json to enable strict rules for specific folders or files and fix the errors.
  2. Folder-by-Folder Migration:

    • Address the following folders and files in sequence:
      • src/Batch/
      • src/Errors/
      • src/Transaction/
      • src/AbstractFirestoreRepository.ts
      • src/BaseFirestoreRepository.ts
      • src/BaseRepository.ts
      • src/helpers.ts
      • src/MetadataStorage.ts
      • src/QueryBuilder.ts
      • src/utils.ts
  3. Final Integration:

    • After migrating all folders and files, remove the inner tsconfig.json.
    • Enable strict: true in the outer tsconfig.json.

Example Implementation

// Update tsconfig.json to enable strict rules
{
  "compilerOptions": {
    // other options...
    "strict": true
  },
  "include": [
    "src/**/*.ts"
  ]
}

// Fix TypeScript errors in migrated files
export class ExampleClass {
  // Ensure all properties are properly typed
  private exampleProperty: string;

  constructor(exampleProperty: string) {
    this.exampleProperty = exampleProperty;
  }
}

Original Issue