Skip to main content

ADR 0001 β€” Temporary JavaScript in Firebase Functions

Context​

The Engineering Handbook mandates TypeScript across apps and packages with strict mode. Our Firebase Functions under apps/functions are currently authored in JavaScript (ESM) to accelerate initial integration work and unblock OAuth/provider flows while the broader repository stabilizes.

Decision​

Allow a temporary exception to the "TypeScript everywhere" policy for apps/functions, permitting ESM JavaScript with Node 20 runtime during the bootstrap phase. The exception is narrow: only apps/functions is in scope; all other work remains TypeScript under strict settings.

Consequences​

  • Pros: Faster iteration for provider OAuth flows and token refresh logic; reduced friction during early integration.
  • Cons: We lose compile‑time type safety in Functions; potential drift from TS conventions; slightly higher maintenance cost until migration.

Mitigations​

  • Keep public handler surfaces small and documented; prefer pure helpers where possible for easy TS migration.
  • Maintain ESM and consistent lint/format settings; validate environment variables with runtime checks.
  • Add minimal unit tests in a follow‑up to guard key helpers.

Migration Plan​

  1. Introduce a tsconfig.json and tsup build in apps/functions.
  2. Incrementally convert modules to TypeScript, starting with config and provider helpers; keep export surfaces stable.
  3. Remove this exception once Functions build successfully as TS and CI passes.

Alternatives Considered​

  • Immediate TS migration: rejected for schedule risk; provider work is on the critical path.
  • Keeping JS permanently: rejected; long‑term policy is TS everywhere.