Skip to content

Fix cra frozen tsconfig#423

Merged
CasperL1218 merged 4 commits into
mainfrom
fix-cra-frozen-tsconfig
Apr 17, 2026
Merged

Fix cra frozen tsconfig#423
CasperL1218 merged 4 commits into
mainfrom
fix-cra-frozen-tsconfig

Conversation

@CasperL1218
Copy link
Copy Markdown
Contributor

Summary

  • Persist a one-line fix to react-scripts@4.0.0 via patch-package so Heroku builds don't crash
  • Remove redundant import firebase from 'firebase/app' in ApartmentPage.tsx that caused a TypeScript type
    mismatch across the codebase

Details:

  • verifyTypeScriptSetup.js in CRA assigns appTsConfig = readTsConfig (same reference), then passes
    readTsConfig through immer which freezes it. Any subsequent write to appTsConfig.compilerOptions crashes
    with TypeError: Cannot assign to read only property. Fix: deep-copy via JSON.parse(JSON.stringify(...)) before
    assigning.
  • The patch was previously applied manually to node_modules (lost on every fresh install). patch-package + a
    postinstall script now re-applies it automatically after every yarn install, including on Heroku.

Test Plan

Deploy to cuapts-staging — build should succeed without the TypeError: Cannot assign to read only property 'jsx' crash.

Notes

  • The patch targets exactly react-scripts@4.0.0. If/when react-scripts is upgraded (Phase 3 dependency
    upgrades), this patch file should be deleted — patch-package will error loudly on install if the patch no longer
    applies, making it easy to catch.
  • firebase/app import removal in ApartmentPage.tsx: the import was only used for the firebase.User type
    annotation. All other files in the codebase rely on the ambient Firebase namespace for this type — the explicit
    default import created a firebase.User vs firebase.default.User split that TypeScript treated as incompatible.

  Replaces window.confirm() with a MUI Dialog that requires the admin to
  type 'CONFIRM' before the schema migration can proceed, preventing
  accidental batch-writes to all apartment records.
  patch-package: deep-copy readTsConfig in verifyTypeScriptSetup.js so
  appTsConfig stays mutable after immer freezes the original. Persisted
  via patch-package postinstall so the fix survives yarn install on Heroku.

  Also remove redundant 'import firebase from firebase/app' in
  ApartmentPage.tsx — only used for type annotations, and caused a
  firebase.User vs firebase.default.User mismatch across 23 other files
  that rely on the ambient namespace type.
@dti-github-bot
Copy link
Copy Markdown
Member

[diff-counting] Significant lines: 64.

Copy link
Copy Markdown

@bryanshao07 bryanshao07 left a comment

Choose a reason for hiding this comment

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

Looks good, solves two small issues, and makes it easier to run a migration.

@CasperL1218 CasperL1218 merged commit cce7aa4 into main Apr 17, 2026
4 checks passed
@CasperL1218 CasperL1218 deleted the fix-cra-frozen-tsconfig branch April 17, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants