Description
Neither /backend/tsconfig.json nor /client/tsconfig.json enables TypeScript strict mode. Without strict mode, common bugs like null/undefined dereferences, implicit any parameters, and uninitialized class properties go undetected at compile time.
Current State
// tsconfig.json (likely)
{
"compilerOptions": {
"strict": false // or not set
}
}
Fix
Enable strict mode
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true
}
}
The strict flag enables:
strictNullChecks — catches null/undefined bugs
strictFunctionTypes — proper function type variance
strictBindCallApply — type-safe bind/call/apply
strictPropertyInitialization — catches uninitialized class fields
noImplicitAny — forces explicit types
Migration Strategy (incremental)
Enabling strict on a large codebase will produce many errors. Use incremental migration:
Step 1: Enable strictNullChecks only
Fix all null/undefined errors first. This has the highest ROI for bug prevention.
Step 2: Enable noImplicitAny
Fix all implicit any types.
Step 3: Enable full strict: true
For each step: use // @ts-expect-error with a TODO comment for errors you can't fix immediately, tracking them as tech debt.
Why This Matters for SYNCRO
The subscription service currently uses any types extensively. With strictNullChecks, the compiler would have caught potential null dereferences on subscription fields before they cause runtime errors.
Acceptance Criteria
Description
Neither
/backend/tsconfig.jsonnor/client/tsconfig.jsonenables TypeScript strict mode. Without strict mode, common bugs likenull/undefineddereferences, implicitanyparameters, and uninitialized class properties go undetected at compile time.Current State
Fix
Enable strict mode
{ "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "noUnusedLocals": true, "noUnusedParameters": true } }The
strictflag enables:strictNullChecks— catches null/undefined bugsstrictFunctionTypes— proper function type variancestrictBindCallApply— type-safe bind/call/applystrictPropertyInitialization— catches uninitialized class fieldsnoImplicitAny— forces explicit typesMigration Strategy (incremental)
Enabling strict on a large codebase will produce many errors. Use incremental migration:
Step 1: Enable
strictNullChecksonlyFix all null/undefined errors first. This has the highest ROI for bug prevention.
Step 2: Enable
noImplicitAnyFix all implicit any types.
Step 3: Enable full
strict: trueFor each step: use
// @ts-expect-errorwith a TODO comment for errors you can't fix immediately, tracking them as tech debt.Why This Matters for SYNCRO
The subscription service currently uses
anytypes extensively. WithstrictNullChecks, the compiler would have caught potential null dereferences on subscription fields before they cause runtime errors.Acceptance Criteria
strictNullChecks: trueenabled in both tsconfigs!.non-null assertions on untrusted data)noImplicitAny: trueenabled