Keep TypeScript strict while agents generate code

TypeScript agents often escape pressure with any, loose casts, and broken path aliases.

Published 2026-11-09 · Translation: VI

TypeScript agents often escape pressure with any, loose casts, and broken path aliases. Keep strictness as a gate: type-first prompts, no new any without justification, and CI that fails on looseness. The trap is accepting as any “just to unblock” a feature that now hides a future blind spot.

Strictness is a merge gate

Typefirst

Typefirst

Confirm compiler strict options are on and documented for contributors and agents. Prompt with existing types and the repo’s path alias patterns. Related: Rules files that agents obey for encoding the no-any rule once.

Type-first before implementation sprawl

  1. Attach the types and alias patterns the change must respect.
  2. Draft public types first for new surfaces.
  3. Implement against those types, then typecheck after edits.
  4. Isolate truly unknown external SDKs behind a typed boundary module instead of spraying casts.
  5. Reject PRs that disable strict checks or add widespread eslint ignores for types.

Periodically hunt new any introductions with review bots or a ripgrep gate on diffs.

Three traps that show up first

Failure modes to catch early

Failure modes to catch early

  • any unblock. as any or eslint ignore lands to “ship.” Fix: require a typed boundary or a tracked exception with an owner.
  • Code before types. Public shapes invent themselves in the implementation. Fix: type-first gate for API changes.
  • Alias drift. Imports work on one machine’s config. Fix: reuse existing alias schemes only; CI must compile the same paths.

A one-week practice loop

This week: confirm tsc --noEmit is in the agent DoD and ripgrep the last five agent PRs for any / as unknown as. Next week: reject one PR that uses an escape and document the accept/reject example in the rules file.

Bottom line

When this fits vs when it does not

When this fits vs when it does not

Keep TypeScript strict by refusing escapes, prompting type-first, and mirroring CI locally. Agents generate faster when types already constrain the surface. For other language cultures, see Rust and Go agent caveats.

Share

X Facebook LinkedIn
Educational content only. Rankings reflect stated criteria at the update date—not investment advice or permanent performance guarantees.