What is TypeScript?
TypeScript is JavaScript with types, developed by Microsoft. It compiles to plain JavaScript that runs anywhere JavaScript runs.
Programming language. Updated by DATAL Projects
- Made by
- Microsoft
- First released
- 2012
- License
- Apache 2.0 (open source)
- Type
- Typed programming language
- Runs on
- Anywhere JavaScript runs, after compiling
- Official site
- typescriptlang.org
What TypeScript is
TypeScript is JavaScript with types, developed by Microsoft. It compiles to plain JavaScript that runs anywhere JavaScript runs. Types catch many mistakes before the code runs and make large projects easier to maintain and hand over.
TypeScript was developed at Microsoft and announced in 2012. Its lead designer is Anders Hejlsberg, who also designed C#. It was made because large JavaScript programs were hard to maintain without types and good editor support.
Version 1.0 came out in 2014. Adoption grew when Angular chose TypeScript as its main language, and again as editors such as Visual Studio Code made its features visible to everyday JavaScript developers. Today most major frameworks and libraries ship with TypeScript types.
How TypeScript works
TypeScript is a superset of JavaScript. That means valid JavaScript is also valid TypeScript, and TypeScript adds a layer of type annotations on top. A type says what kind of value something is, such as a string, a number, or an object with certain fields.
The TypeScript compiler, called tsc, reads your code and checks that values are used in ways that match their types. If you pass a number where text is expected, you get an error in your editor before the program runs. This is called static type checking.
Browsers do not run TypeScript directly. The types are removed in a build step, and what is left is plain JavaScript. Because the types are erased, they add no cost when the program runs. Settings for the compiler live in a file named tsconfig.json.
Key features of TypeScript
Static type checking
Many mistakes, such as typos in property names or missing values, are found while you type instead of in production.
Type inference
TypeScript works out most types on its own from the values you assign. You do not need to annotate every variable.
Better editor support
Autocomplete, go to definition, and safe renaming all rely on type information. This speeds up work in large codebases.
Interfaces and generics
Interfaces describe the shape of objects, and generics let one function or component work safely with many types.
Gradual adoption
You can add TypeScript to an existing JavaScript project one file at a time. Strictness can be raised as the code improves.
Types for libraries
Most popular packages include type definitions or have them available from the community. Your editor then knows how each library should be used.
When to use TypeScript
A good choice for
- Medium and large projects that will be maintained for years
- Teams where several people work on the same code
- APIs and data models where the shape of data matters
- Projects that share code between frontend and backend
- Libraries that other developers will use
Pick something else when
- Very small scripts where a build step is not worth it
- Complete beginners who have not learned JavaScript basics yet
- Quick throwaway prototypes where speed matters more than safety
TypeScript compared with alternatives
TypeScript vs JavaScript
JavaScript is the language that actually runs. TypeScript is JavaScript plus types that are checked before the code runs and then removed. TypeScript takes a little more setup and gives more safety in return.
TypeScript vs JSDoc type comments
You can write types inside comments in plain JavaScript files and still have them checked by the TypeScript tooling. This avoids a compile step. The syntax is more wordy, so most application teams prefer TypeScript files.
TypeScript vs Flow
Flow is a type checker for JavaScript made by Meta. It solves a similar problem, but TypeScript has far wider adoption, tooling, and library support outside of Meta.
How to start learning TypeScript
- 01Learn core JavaScript first, since everything in TypeScript builds on it.
- 02Read TypeScript for JavaScript Programmers and then the Handbook on typescriptlang.org.
- 03Try small examples in the official online Playground, which shows the JavaScript output next to your code.
- 04Add it to a small project with npm install typescript --save-dev and create a tsconfig.json with strict mode turned on.
- 05Convert one of your existing JavaScript projects file by file, fixing the errors the compiler reports.
What TypeScript costs
TypeScript is free and open source under the Apache 2.0 license. The compiler, the language service used by editors, and the documentation are all free. There are no paid tiers.
How DATAL Projects uses TypeScript
TypeScript is part of our software development work in the Philippines. Common uses:
- Frontend and backend code
- APIs and integrations
- Shared code between web and desktop apps
Common questions about TypeScript
Is TypeScript free?
Yes. TypeScript is open source under the Apache 2.0 license and free for any use. Microsoft maintains it in public on GitHub.
TypeScript vs JavaScript: which should I use?
Learn JavaScript first, because TypeScript is built on it. For real projects that will grow or be shared with a team, TypeScript is usually the better choice. For tiny scripts, plain JavaScript is fine.
Is TypeScript hard to learn?
If you know JavaScript, the basics take a few days. Advanced features such as generics and conditional types take longer, but most everyday code only needs the simple parts.
Does TypeScript make my app slower?
No. Types are removed before the code runs, so the browser or server runs ordinary JavaScript. The only added time is in the build step during development.
Is TypeScript worth learning?
Yes. It is used by most modern web frameworks and is a common requirement in frontend and Node.js job listings. It also makes you better at reading and designing code.
Need a project built with TypeScript?
Tell us what you need. We reply with a scope, a price, and a timeline.
Start a Project
