TypeScript is a programming language developed by Microsoft that adds optional static types to JavaScript. Every valid JavaScript program is also valid TypeScript, and the TypeScript compiler checks types and then emits plain JavaScript that runs in browsers or on Node.js.
Why it matters
Types catch many mistakes, such as misspelled properties or wrong argument types, before the code runs, and they give editors accurate autocomplete and safe refactoring. This is valuable in large front-end and Node.js codebases with many contributors. Types exist only at compile time and are erased in the output, so they do not validate data arriving at runtime, such as an API response.
Example
interface Site {
host: string;
up: boolean;
}
function label(s: Site): string {
return s.up ? `${s.host} is up` : `${s.host} is down`;
}
label({ host: "example.com", upp: true }); // compile error: 'upp'
The misspelled property is flagged before the code is ever executed.
Common mistakes
- Overusing
any, which switches off type checking. - Assuming a type annotation validates untrusted JSON at runtime.
- Casting with
asto silence errors instead of fixing the underlying mismatch.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.