Technical guide · TypeScript and AI-assisted development
Tech Lead and TypeScript/Next.js developer at Byrds Consulting.
A code agent can produce a plausible diff that uses an old signature or misses a case. TypeScript checks the proposal against the repository’s contracts and flags some errors before review.
Repository context
Give the agent the project’s actual signatures
In August 2025, TypeScript became the most-used language on GitHub by monthly contributors. That metric does not represent the entire industry, but it confirms a shift already visible across product teams: typed JavaScript is now part of the standard web development toolkit.
TypeScript covers the browser, React and Next.js, Node.js APIs, workers, and much of the surrounding tooling. A team can use one language from the frontend to the server. That convenience stops at runtime boundaries: a TypeScript interface does not validate JSON received from an API, a database, or an LLM.
What the agent can read and check
The benefit goes beyond autocomplete. Types make some of the project’s expectations explicit to developers, editors and code agents.
- A broad, well-documented ecosystem that web teams already know.
- Explicit contracts between components, services, and libraries.
- Diagnostics available in the editor, locally, and in CI.
Working with a code agent
Check the diff against declared contracts
A model generates plausible code. It may invent a property, miss a branch in a union, or call a function using an outdated signature. The compiler cannot tell whether a feature is useful, but it can compare the diff with the contracts that exist in the repository.
Code agents are generally familiar with common TypeScript APIs and patterns. That makes a first pass faster, but it does not guarantee a match with the installed version or local conventions. Diagnostics from the type checker bring the agent back to the codebase it is actually changing.
Context close to the code
Function signatures, generics, and return types describe expected shapes without copying every detail into the prompt.
Actionable diagnostics
The compiler points to the file, line and contract that no longer matches. The agent has a precise starting point for the next fix.
Visible refactor impact
Changing a shared type surfaces call sites that also need an update, including files missing from the first diff.
Missing cases caught
An exhaustiveness check on a discriminated union catches any declared variant that has not been handled.
The type checker answers a narrow question: is this code compatible with the declared contracts? It cannot validate the product requirement, but its answer is fast and repeatable.
The feedback loop
Generate a small diff, check it, then review it
A good task for an agent has one clear goal. It states the expected behaviour, the relevant files, and the constraints that must remain intact. The first diff can then be checked with the repository’s own commands instead of relying on an abstract description of the project.
Errors from tsc --noEmit give the agent a concrete correction list. Once the automated checks pass, review can focus on everything they do not cover: intended behaviour, readability, operational risk, and whether the tests are meaningful.
Scoped task
One goal, clear acceptance criteria, and an explicit boundary.
TypeScript diff
The agent follows contracts and conventions already present in the repository.
Project checks
Type checking, linting, tests and the build surface regressions that those tools can detect.
Human review
A person reviews behaviour, trade-offs, and side effects before merge.
type Job =
| { status: 'queued' }
| { status: 'done'; url: string }
| { status: 'failed'; message: string }
function assertNever(value: never): never {
throw new Error(`Unhandled job: ${JSON.stringify(value)}`)
}
function jobLabel(job: Job): string {
switch (job.status) {
case 'queued': return 'Queued'
case 'done': return job.url
case 'failed': return job.message
default: return assertNever(job)
}
}If the first diff omits the failed branch, assertNever(job) no longer compiles: job can still contain that state. The diagnostic tells the agent which case to handle. A person must then check that the displayed message and interface behaviour fit the product. This check assumes incoming data has already been validated at runtime.
The boundary with external data
Typed code still needs to validate its inputs
The same issue arises when an agent changes a feature that calls a model. Data received from an API, database or LLM needs runtime validation. Types alone do not perform that check.
Libraries used for these features have their own contracts. Vercel’s AI SDK provides structured output and schema-validated tools; TanStack AI includes typed tools and streaming. Capabilities depend on versions, providers and models. The TanStack AI beta status described in the sources also matters when choosing and maintaining the integration.
01
Validate external data
Zod, Valibot, or JSON Schema can reject a malformed call. Domain checks, such as access to a resource or a valid date range, still need explicit service logic.02
Keep each tool contract narrow
A tool with a few well-named parameters and a documented result is easier to call, test, and evolve than a generic function that exposes an entire service.03
Review the resulting behaviour
A diff can compile while choosing the wrong API, swallowing an error, or adding an unnecessary dependency. Review should cover those decisions, not just code shape.
The same schema can drive a tool call and its handler when both describe the exact same contract. API, domain, and persistence models should not be collapsed into one shape just to avoid a little mapping code.
Useful limits
A passing typecheck does not validate a feature
With strict mode enabled, the compiler can catch a missing property, an unhandled undefined value or an incompatible response. It cannot tell whether a business rule is correct, whether a user is allowed to act or whether a query returns the right data. Those concerns still require runtime checks, focused tests and careful review.
What TypeScript actually provides
Fast feedback on a specific class of errors that appears in generated and handwritten changes alike.
- Signature mismatches can be detected before deployment.
- Changing a type reveals which consumers must be updated as well.
- AI tools can combine runtime validation and static inference from one schema.
- any, type assertions, and unvalidated data can still bypass these guarantees.
The check that remains with the team
Once type checking passes, review still needs to cover business rules, authorisation and shipped behaviour. A compiler cannot decide whether the feature meets the requirement.
Sources and documentation
- Octoverse 2025: AI leads TypeScript to #1. GitHub. Data and methodology for TypeScript usage in 2025.
- TypeScript: JavaScript with syntax for types. TypeScript. Official overview of the language, its type inference, and gradual adoption.
- TSConfig: strict and noEmit. TypeScript. Reference for strict checks and using the compiler as a type checker.
- AI SDK Core: Tools and tool calling. Vercel AI SDK. Input schemas, tool-call validation, and parameter inference.
- AI SDK introduction. Vercel AI SDK. Current overview of the TypeScript toolkit and its Core and UI APIs.
- TanStack AI overview. TanStack. Documentation for the typed core, tools, and provider adapters.
- TanStack AI Beta. TanStack. Current project status and the implications of its beta phase.
