TypeScript

Hand-drawn flowing terracotta shapes, each traced by a thin outline, among cream, sand, umber and moss contour lines.

TypeScript extends JavaScript with optional type annotations, which describe the kinds of values code expects. Its checker can flag likely errors before the program runs. A historical test found bugs the checker could catch, while the effect of adopting TypeScript on defect rates in ongoing projects remains uncertain. (Rastogi et al., 2015; Microsoft TypeScript Team, n.d.d; Gao et al., 2017b; Bogner & Merkel, 2022)

Origins and design goals

Microsoft designed TypeScript 1.0 for large JavaScript applications. It released version 0.8 in October 2012 and announced version 1.0 in April 2014. The 2012 unveiling advertised static typing for developer tools alongside class syntax and a preview of ECMAScript 6, an upcoming edition of the JavaScript standard. (Turner, 2014; Øredev, 2012)

The design goals pair early error detection with a way to organise larger programs. They also call for preserving how JavaScript code behaves when it runs. (Microsoft TypeScript Team, n.d.d)

Type compatibility and erasure

TypeScript generally checks whether a value supplies the properties and methods that the receiving code expects. This is called structural typing. For example, code that expects an object with a text property named name can accept an object that also has an age property. Declaring those objects under different type names ordinarily leaves that compatibility intact. (Microsoft TypeScript Team, n.d.c)

Type erasure means removing type annotations from the code that runs. Erasure and checking are separate operations. Node.js illustrates the distinction because it can execute TypeScript files whose extra syntax can all be erased. In that mode, it strips the TypeScript syntax and runs the resulting JavaScript without checking the types. (Node.js, n.d.c)

Limits of the checker

TypeScript deliberately allows some operations whose safety the checker cannot establish in advance. This choice is called unsoundness. Passing the checker can therefore leave some type errors to appear during execution. The language team framed the choice as a balance between correctness and developer productivity. (Microsoft TypeScript Team, n.d.c; Microsoft TypeScript Team, n.d.d)

Checking external data and imports

A type assertion, such as value as User, tells the checker to treat the value as a particular type. The assertion disappears during compilation and performs no runtime validation. A JSON value with a missing field can still reach code that expects it. (Microsoft TypeScript Team, n.d.a)

An import can pass type checking and still fail when the program starts. For example, TypeScript’s paths setting can tell the checker where to find a module while leaving the import name in the generated JavaScript intact. (Microsoft TypeScript Team, n.d.b)

Runtime checks in Safe TypeScript Weak evidence: few or small studies support this

A research prototype called Safe TypeScript caught type errors by adding checks during execution. Running those checks while building the prototype’s own compiler took 15% longer than building it with the checks disabled. Preliminary work on a later compiler version found higher costs for checking structural types. (Rastogi et al., 2015)

Bugs the checker can flag Weak evidence: few or small studies support this

Type checking could have flagged a minority of past JavaScript bugs; Type systems covers this kind of evidence across languages. TypeScript 2.0 and Flow 0.30, another JavaScript type checker, each flagged about 15% of 400 public bugs. Researchers added the annotations by hand, guided by the eventual fixes (Gao et al., 2017b).

The result depended on the checker version. TypeScript 2.0 could flag 22 bugs in the sample that version 1.8 could not (Gao et al., 2017b).

TypeScript changes by coding agents

Type errors during editing Weak evidence: few or small studies support this

The type errors an AI coding agent sees can depend on how it edits files. In a repository experiment, Claude Code saw type errors during 23 of 39 TypeScript runs when forced to use the edit tool its plugin monitored. Across the configurations with the plugin, nine runs failed without receiving type diagnostics. (Nazarova, 2026)

Correct syntax alone would have removed relatively few compilation failures in two benchmarks of generated TypeScript functions. Ideal syntax enforcement could have reduced the number of failures by at most 9.0% on HumanEval and 4.8% on MBPP. (Mündler et al., 2025)

Explicit any and type assertions Weak evidence: few or small studies support this

Agents added more explicit any annotations than people did in one comparison of pull requests selected for type-related changes. The any type lets code use a value without the usual checks on its type. Agents added an average of 2.16 explicit any annotations per pull request in that sample, compared with 0.24 for people. (Lee et al., 2026c; typescript-eslint, n.d.a)

The same sample showed more type assertions and more non-null assertions in agent changes. A non-null assertion tells the checker to assume a value is neither null nor undefined. The study counted these forms by matching patterns in source text. (Lee et al., 2026c)

Explicit any can be absent from agent changes. In a comparison on one feature with fixed strict settings, both the human and agent versions used zero explicit any annotations in application code. (Integrity Constraint, n.d.)

A lint rule can flag a deliberately written any annotation. The rule catches explicit any annotations that the compiler’s noImplicitAny option does not reject. (typescript-eslint, n.d.a)

Repairs to asynchronous code Weak evidence: few or small studies support this

Coding agents can clear a lint warning about an ignored promise while leaving the bug in place. A promise represents the eventual result or failure of an operation. In a lint vendor’s experiment on two existing bugs, all 16 runs by Claude Code and Codex cleared the warning, and three passed the behaviour check. (Bleasel, n.d.)

Twelve of the repairs used void to mark the promise as intentionally ignored, which leaves its failure unhandled. The experiment asked agents to preserve runtime behavior, a constraint Claude Code cited when leaving the bug in place. (Bleasel, n.d.; typescript-eslint, n.d.b)

Code quality and defects in projects

Comparisons of existing repositories found fewer signs of hard-to-maintain code in TypeScript projects. Among 604 open-source front-end web applications, TypeScript projects had fewer code smells, patterns that indicate a potential maintenance problem, per line. An independent thesis comparing ten projects per language likewise found more code smells in the JavaScript projects (Bogner & Merkel, 2022; Ferreira, 2023).

The same 604-project comparison leaves the effect on defects unresolved. TypeScript projects averaged 20.6% of commits classified as bug fixes, against 12.6% for JavaScript, but the classification relied on words in commit messages and team differences could affect it (Bogner & Merkel, 2022). The wider dispute over static typing and defects is covered in Type systems.

Kinds of reported faults Weak evidence: few or small studies support this

Tooling and configuration problems made up the largest category in a study of 633 bug reports from 16 TypeScript projects. An older JavaScript study classified bugs partly by whether they involved a webpage’s document structure. The two studies’ categories overlap only in part, which limits what their percentages can say about the effect of typing. (Tang et al., 2026a; Ocariza et al., 2017)

How developers read type information Weak evidence: few or small studies support this

The presence of type annotations or declarations did not draw more direct looks to those lines in a small eye-tracking experiment. The 26 undergraduate participants summarised TypeScript code and looked for the locations of bugs. The study measured where participants looked, leaving open whether type information makes professional developers faster or more accurate. (Flint et al., 2026)

Use in practice

TypeScript use shows up both in survey responses and in repository activity. Among the 14,099 people who answered the 2026 Stack Overflow language question, 43.8% reported extensive development work with TypeScript in the preceding year. Respondents could select multiple languages, and 62% reported JavaScript. On GitHub, TypeScript ranked first in August 2025 by monthly contributors, with about 2.64 million. (Stack Overflow, 2026; GitHub Staff, 2025)

Further reading

Known gaps

What this article cannot tell you yet.

  1. The historical estimate of detectable bugs lacks an independent replication using the same method.
  2. The effect of adopting TypeScript on project defect rates has no controlled estimate here.
  3. The effect on workplace productivity remains open.
  4. How often type checks and behaviour tests flag the same defects in final TypeScript patches from coding agents remains unclear.
  5. The frequency of agent-introduced errors in runtime validation, module loading and asynchronous code remains unclear.
  6. The frequency with which type assertions in agent changes lead to runtime failures remains unclear.

References

Solid source
Rated highly trustworthy by the research, and every passage taken from it was found in it.
Weak source
Rated low, or a passage taken from it was not found in it.
Medium trust
Rated medium by the research.
Not checked
Rated high, but its passages could not all be checked against it.
Show all 23 references