TypeScript Standards and Governance
This document defines the TypeScript baseline and governance model for Freeboard.
Baseline Requirements
- TypeScript strictness is the default posture.
- Product source lives in TS-first paths:
packages/ui/srcpackages/api/srcpackages/gateway/srcpackages/shared/src
- CI must enforce:
- lint,
- TS debt checks,
- source-artifact checks,
- typecheck.
Prohibited Patterns (Product Source)
anytypes andas anycasts.as unknown asdouble-casts.@ts-ignoreand@ts-nocheck.- Catch-all index signatures used as escape hatches.
- Accessing unknown error properties without explicit narrowing.
Allowed Patterns
unknownat trust boundaries (network/input/plugin edges), followed by explicit guards.- Narrow, local casts where there is no safe runtime alternative and a typed helper is used.
- Shared compatibility helpers preferred over repeated inline casts/hacks.
Error Handling Rules
catch (error)variables are treated asunknown.- Narrow before property access:
- check object shape,
- extract known fields safely,
- provide fallback messages/codes.
Script and Tooling Policy
- Scripts may remain
.mjswhen runtime portability and direct Node execution are preferred. - All quality-critical scripts must be linted and run in CI.
- Transitional scripts/config fragments must be removed once no longer needed.
Legacy and Exception Policy
- Non-TS or legacy artifacts kept intentionally must be documented with:
- reason,
- owner,
- reevaluation trigger.
- Temporary exceptions require:
- explicit note in PR,
- follow-up task,
- no silent carry-forward.
Retained Artifacts
Intentional non-TS artifacts:
scripts/*.mjs(selected operational scripts)- Reason: direct Node ESM execution and operational portability.
- Owner: repository maintainers.
- Reevaluate when: script maintenance burden or typing regressions justify TS conversion.
Typed Ownership Map
Ambient declarations and generated-type ownership:
packages/ui/src/types/global.d.ts- Scope: app-wide UI globals.
- Owner: UI maintainers.
packages/ui/src/types/vue-grid-layout-v3.d.ts- Scope: third-party module typing coverage.
- Owner: UI maintainers.
packages/ui/src/vite-env.d.ts- Scope: Vite environment typing.
- Owner: UI maintainers.
Generated typing/model artifacts:
docs/auto/graphql/schema.graphqlanddocs/public/dev/graphql/schema.graphql- Generated from GraphQL schema tooling.
- Owner: API maintainers.
docs/auto/api/*anddocs/public/dev/api/*- Generated API documentation artifacts.
- Owner: repository maintainers.
Validation Baseline
Run for every TypeScript-sensitive change:
bash
npm run format:check
npm run lint
npm run check:ts:debt
npm run check:ts:source-artifacts
npm run typecheck
npm run test
npm run build:verifyFor UI/runtime-affecting changes also run:
bash
npm run test:e2e:smokeTypeScript Regression Prevention Checklist
Apply this checklist to TS-sensitive PRs:
- No
any,as unknown as,@ts-ignore, or@ts-nocheckintroduced. - New trust-boundary parsing starts at
unknownand narrows with guards. - New
.d.tsadditions include scope + owner in this document. npm run lint,npm run check:ts:debt,npm run check:ts:source-artifacts, andnpm run typecheckare all green.- If runtime behavior changed, tests/docs were updated in the same PR.