Overview
Several Zustand store action callsites use as Type casts to suppress nullable type errors — e.g., setUser(response.data.user as User) where data.user may be undefined when API response validation is absent. With strict: true in tsconfig.json, TypeScript would catch these as errors if not for the casts. Each unsafe cast hides a potential runtime crash or data corruption.
Specifications
Features:
- Zero
as Type casts used to suppress nullable errors in store action callsites
- All nullable API response fields narrowed with explicit guards before store dispatch
exactOptionalPropertyTypes: true added to tsconfig.json
Tasks:
- Run
grep -rn ' as [A-Z][A-Za-z]*[>;,]' src/ to enumerate suspicious casts
- For each cast: determine if null is actually possible; add explicit guard or fix upstream type
- Remove unsafe casts; replace with type narrowing (
if (!user) return; etc.)
- Add
exactOptionalPropertyTypes: true to tsconfig.json if not present
- Verify
tsc --noEmit passes with zero errors after all changes
Impacted Files:
src/store/slices/ (all slice files)
tsconfig.json
Acceptance Criteria
- Zero
as Type casts bypass nullable checks in store action calls
tsc --noEmit passes with zero type errors after changes
exactOptionalPropertyTypes: true in tsconfig.json
- No new
@ts-ignore or @ts-expect-error suppressions introduced
Overview
Several Zustand store action callsites use
as Typecasts to suppress nullable type errors — e.g.,setUser(response.data.user as User)wheredata.usermay beundefinedwhen API response validation is absent. Withstrict: trueintsconfig.json, TypeScript would catch these as errors if not for the casts. Each unsafe cast hides a potential runtime crash or data corruption.Specifications
Features:
as Typecasts used to suppress nullable errors in store action callsitesexactOptionalPropertyTypes: trueadded totsconfig.jsonTasks:
grep -rn ' as [A-Z][A-Za-z]*[>;,]' src/to enumerate suspicious castsif (!user) return;etc.)exactOptionalPropertyTypes: truetotsconfig.jsonif not presenttsc --noEmitpasses with zero errors after all changesImpacted Files:
src/store/slices/(all slice files)tsconfig.jsonAcceptance Criteria
as Typecasts bypass nullable checks in store action callstsc --noEmitpasses with zero type errors after changesexactOptionalPropertyTypes: trueintsconfig.json@ts-ignoreor@ts-expect-errorsuppressions introduced