TypeScript explained

TypeScript
Paradigm:Multi-paradigm

functional, generic, imperative, object-oriented

Family:ECMAScript
Designer:Microsoft,
Anders Hejlsberg,
Luke Hoban
Developer:Microsoft
Released:[1]
Typing:Duck, gradual, strong, structural[2]
Scope:Lexical
License:Apache 2.0
File Ext:.ts, .tsx, .mts, .cts
Influenced By:C#, F#,[3] Java, JavaScript, ActionScript[4]
Influenced:AtScript, AssemblyScript, ArkTS

TypeScript (TS) is a high-level programming language that adds static typing with optional type annotations to JavaScript. It is designed for developing large applications. It transpiles to JavaScript.[5] It is developed by Microsoft as free and open-source software released under an Apache License 2.0.

TypeScript may be used to develop JavaScript applications for both client-side and server-side execution (as with React.js, Node.js, Deno or Bun). Multiple options are available for transpiling. The default TypeScript Compiler can be used,[6] or the Babel compiler can be invoked to convert TypeScript to JavaScript.

TypeScript supports definition files that can contain type information of existing JavaScript libraries, much like C++ header files can describe the structure of existing object files. This enables other programs to use the values defined in the files as if they were statically typed TypeScript entities. There are third-party header files for popular libraries such as jQuery, MongoDB, and D3.js. TypeScript headers for the Node.js library modules are also available, allowing development of Node.js programs within TypeScript.[7]

The TypeScript compiler is written in TypeScript and compiled to JavaScript. It is licensed under the Apache License 2.0. Anders Hejlsberg, lead architect of C# and creator of Delphi and Turbo Pascal, has worked on developing TypeScript.[8] [9] [10] [11]

History

TypeScript was released to the public in October 2012, with version 0.8, after two years of internal development at Microsoft.[12] [13] Soon after the initial public release, Miguel de Icaza praised the language, but criticized the lack of mature integrated development environment (IDE) support apart from Microsoft Visual Studio, which was unavailable then on Linux and macOS.[14] [15] As of April 2021 there is support in other IDEs and text editors, including Emacs, Vim, WebStorm, Atom[16] and Microsoft's own Visual Studio Code.[17] TypeScript 0.9, released in 2013, added support for generics.[18]

TypeScript 1.0 was released at Microsoft's Build developer conference in 2014.[19] Visual Studio 2013 Update 2 provided built-in support for TypeScript.[20] Further improvement were made in July 2014, when the development team announced a new TypeScript compiler, asserted to have a five-fold performance increase. Simultaneously, the source code, which was initially hosted on CodePlex, was moved to GitHub.[21]

On 22 September 2016, TypeScript 2.0 was released, introducing several features, including the ability for programmers to optionally enforce null safety,[22] to mitigate what's sometimes referred to as the billion-dollar mistake.

TypeScript 3.0 was released on 30 July 2018,[23] bringing many language additions like tuples in rest parameters and spread expressions, rest parameters with tuple types, generic rest parameters and so on.[24]

TypeScript 4.0 was released on 20 August 2020.[25] While 4.0 did not introduce any breaking changes, it added language features such as Custom JSX Factories and Variadic Tuple Types.

TypeScript 5.0 was released on 16 March 2023 and included support for decorators.[26]

On March 11, 2025, Anders Hejlsberg announced on the TypeScript blog that the team is working on a Go port of the TypeScript compiler to be released as TypeScript version 7.0 later this year. It is expected to feature a 10x speedup.[27]

Design

TypeScript originated from the shortcomings of JavaScript for developing large-scale applications both at Microsoft and among their external customers.[28] Challenges with dealing with complex JavaScript code led to demand for custom tooling to ease developing of components in the language.[29]

Developers sought a solution that would not break compatibility with the ECMAScript (ES) standard and its ecosystem, so a compiler was developed to transform a superset of JavaScript with type annotations and classes (TypeScript files) back into vanilla ECMAScript 5 code. TypeScript classes were based on the then-proposed ECMAScript 6 class specification to make writing prototypal inheritance less verbose and error-prone, and type annotations enabled IntelliSense and improved tooling.

Features

TypeScript adds the following syntax extensions to JavaScript:

Syntactically, TypeScript is very similar to JScript .NET, another Microsoft implementation of the ECMA-262 language standard that added support for static typing and classical object-oriented language features such as classes, inheritance, interfaces, and namespaces. Other inspirations include Java and C#.

Compatibility with JavaScript

As TypeScript is simply a superset of JavaScript, existing JavaScript can be adapted to TypeScript and TypeScript program can seamlessly consume JavaScript. The compiler can target all ECMAScript versions 5 and above, transpiling modern features like classes and arrow functions to their older counterparts.

With TypeScript, it is possible to use existing JavaScript code, incorporate popular JavaScript libraries, and call TypeScript-generated code from other JavaScript.[31] Type declarations for these libraries are usually provided with the source code but can be declared or installed separately if needed.

Development tools

See also: List of TypeScript software and tools.

Compiler

The TypeScript compiler, named tsc, is written in TypeScript. As a result, it can be compiled into regular JavaScript and can then be executed in any JavaScript engine (e.g. a browser). The compiler package comes bundled with a script host that can execute the compiler. It is also available as a Node.js package that uses Node.js as a host. The compiler is currently being rewritten in Go for version 7.[32]

The compiler can target a given edition of ECMAScript (such as ECMAScript 5 for legacy browser compatibility), but by default compiles for the latest standards.

IDE and editor support

Integration with build automation tools

Using plug-ins, TypeScript can be integrated with build automation tools, including Grunt (grunt-ts[38]), Apache Maven (TypeScript Maven Plugin[39]), Gulp (gulp-typescript[40]) and Gradle (TypeScript Gradle Plugin[41]).

Linting tools

TSLint[42] scans TypeScript code for conformance to a set of standards and guidelines. ESLint, a standard JavaScript linter, also provided some support for TypeScript via community plugins. However, ESLint's inability to leverage TypeScript's language services precluded certain forms of semantic linting and program-wide analysis.[43] In early 2019, the TSLint team announced the linter's deprecation in favor of typescript-eslint, a joint effort of the TSLint, ESLint and TypeScript teams to consolidate linting under the ESLint umbrella for improved performance, community unity and developer accessibility.[44]

Release history

Version numberRelease dateSignificant changes
performance improvements
protected modifier, tuple types
union types, let and const declarations, template strings, type guards, type aliases
ES6 modules, namespace keyword, for..of support, decorators
JSX support, intersection types, local type declarations, abstract classes and methods, user-defined type guard functions
async and await support,
constraints generics, control flow analysis errors, string literal types, allowJs
null- and undefined-aware types, control flow based type analysis, discriminated union types, never type, readonly keyword, type of this for functions
keyof and lookup types, mapped types, object spread and rest,
mix-in classes, object type,
async iteration, generic parameter defaults, strict option
dynamic import expressions, string enums, improved inference for generics, strict contravariance for callback parameters
optional catch clause variables
strict function types
constant-named properties, fixed-length tuples
conditional types, improved keyof with intersection types
support for symbols and numeric literals in keyof and mapped object types
project references, extracting and spreading parameter lists with tuples
mappable tuple and array types
stricter checking for bind, call, and apply
relaxed rules on methods of union types, incremental builds for composite projects
faster incremental builds, type inference from generic functions, readonly modifier for arrays, const assertions, type-checking global this
faster incremental builds, omit helper type, improved excess property checks in union types, smarter union type checking
Stricter generators, more accurate array spread, better Unicode support for identifiers
Optional chaining, nullish coalescing
Type-only imports and exports, ECMAScript private fields, top-level await
Improvements in inference, speed improvements
Variadic tuple types, labeled tuple elements
Template literal types, key remapping in mapped types, recursive conditional types
Smarter type alias preservation, leading/middle rest elements in tuple types, stricter checks for the in operator, abstract construct signatures
Separate write types on properties, override and the --noImplicitOverride flag, template string type improvements
Control flow analysis of aliased conditions and discriminants, symbol and template string pattern index signatures
Type and promise improvements, supporting lib from node_modules, template string types as discriminants, and es2022 module
Type inference and checks improvements, support for ES2022 target, better ECMAScript handling
Support for ES modules, instantiation expressions, variance annotations for type parameters, better control-flow checks and type check improvements
Intersection and union types improvements, better type inference
satisfies operator, auto-accessors in classes (proposal), improvements in type narrowing and checks
ES decorators (proposal), type inference improvements, bundler module resolution mode, speed and size optimizations
Easier implicit returns for undefined and unrelated types for getters and setters
using declarations and explicit resource management, decorator metadata and named and anonymous tuple elements
Improved type narrowing, correctness checks and performance optimizations
6 March 2024Object.groupBy and Map.groupBy support
20 June 2024Inferred Type Predicates, Regular Expression Syntax Checking, and Type Imports in JSDoc
9 September 2024Advanced type inference, variadic tuple enhancements, partial module declarations.
22 November 2024
28 February 2025
31 July 2025
Introduce some deprecations and breaking changes to align with the upcoming native codebase.
Rewrite in Go with faster performance.

See also

References

Sources

Notes and References

  1. Web site: TypeScript . . 26 April 2015 . 3 April 2015 . https://web.archive.org/web/20150403224440/https://typescript.codeplex.com/releases/view/95554 . dead.
  2. Web site: Type Compatibility . TypeScript . 21 March 2018 . 12 March 2018 . https://web.archive.org/web/20180312103740/http://www.typescriptlang.org/docs/handbook/type-compatibility.html . live.
  3. Web site: The Early History of F# . TypeScript was directly influenced by F#: one of the originators of TypeScript was Luke Hoban, who began TypeScript (then called Strada) immediately after working on F# 2.0. Recently he noted the influence of F# on early parts of the TypeScript design [Hoban 2017]. . 5 February 2024 . 9 August 2024 . https://web.archive.org/web/20240809075047/https://fsharp.org/history/hopl-final/hopl-fsharp.pdf . live.
  4. Web site: Nelson . Gary . 28 April 2020 . How ActionScript foreshadowed TypeScript . 9 July 2022 . Medium . en . 9 August 2024 . https://web.archive.org/web/20240809080212/https://javascript.plainenglish.io/how-actionscript-foreshadowed-typescript-149cdb764de9?gi=8d034fbd408d . live.
  5. Web site: Bright. Peter. 3 October 2012. Microsoft TypeScript: the JavaScript we need, or a solution looking for a problem?. 26 April 2015. Ars Technica. Condé Nast. 9 October 2018. https://web.archive.org/web/20181009164414/https://arstechnica.com/information-technology/2012/10/microsoft-typescript-the-javascript-we-need-or-a-solution-looking-for-a-problem/. live. en-US.
  6. Web site: TypeScript Programming with Visual Studio Code. code.visualstudio.com. en. 12 February 2019. 22 September 2022. https://web.archive.org/web/20220922080247/https://code.visualstudio.com/docs/languages/typescript. live.
  7. Web site: borisyankov/DefinitelyTyped . . 26 April 2015 . 1 November 2015 . https://web.archive.org/web/20151101104210/https://github.com/borisyankov/DefinitelyTyped . live.
  8. Web site: Microsoft takes the wraps off TypeScript, a superset of JavaScript. Foley. Mary Jo. 1 October 2012. ZDNet. CBS Interactive. 26 April 2015. 13 November 2014. https://web.archive.org/web/20141113161248/http://www.zdnet.com/microsoft-takes-the-wraps-off-typescript-a-superset-of-javascript-7000004993/. live.
  9. Web site: Somasegar . S. . 1 October 2012 . TypeScript: JavaScript Development at Application Scale . deviated . https://web.archive.org/web/20170926142536/https://blogs.msdn.microsoft.com/somasegar/2012/10/01/typescript-javascript-development-at-application-scale/ . 26 September 2017 . 26 April 2015 . Somasegar's blog . Microsoft.
  10. Web site: Microsoft TypeScript: Can the father of C# save us from the tyranny of JavaScript?. Baxter-Reynolds. Matt. 1 October 2012. ZDNet. 26 April 2015. 3 August 2014. https://web.archive.org/web/20140803030303/http://www.zdnet.com/microsoft-typescript-can-the-father-of-c-save-us-from-the-tyranny-of-javascript-7000005054/. live.
  11. Web site: Microsoft Augments Javascript for Large-scale Development. Jackson. Joab. 1 October 2012. CIO. IDG Enterprise. 26 April 2015. 17 December 2013. https://web.archive.org/web/20131217223751/http://www.cio.com/article/717679/Microsoft_Augments_Javascript_for_Large_scale_Development. dead.
  12. Web site: Microsoft augments JavaScript for large-scale development . 1 October 2012 . . . 26 April 2015 . 31 May 2013 . https://web.archive.org/web/20130531084330/http://www.infoworld.com/d/application-development/microsoft-augments-javascript-large-scale-development-203737 . live.
  13. Web site: Announcing TypeScript 1.0 . 2 April 2014 . Jonathan . Turner . Microsoft . TypeScript Language team blog . 20 October 2021 . 5 September 2015 . https://web.archive.org/web/20150905104620/http://blogs.msdn.com/b/typescript/archive/2014/04/02/announcing-typescript-1-0.aspx . live.
  14. Web site: TypeScript: First Impressions . 1 October 2012 . de Icaza . Miguel . Miguel de Icaza . But TypeScript only delivers half of the value in using a strongly typed language to Unix developers: strong typing. Intellisense, code completion and refactoring are tools that are only available to Visual Studio Professional users on Windows. There is no Eclipse, MonoDevelop or Emacs support for any of the language features. . 12 October 2012 . 24 February 2019 . https://web.archive.org/web/20190224173403/https://tirania.org/blog/archive/2012/Oct-01.html . live.
  15. Web site: Microsoft TypeScript: Can the father of C# save us from the tyranny of JavaScript? . 1 October 2012 . . And I think this is a pretty big misstep. If you're building web apps that run on anything other than Windows, you're likely using a Mac and most likely not using Visual Studio. You need the Visual Studio plug-in to get the IntelliSense. All you get without Visual Studio is the strong-typing. You don't get the productivity benefits you get from IntelliSense. . 12 October 2012 . 3 August 2014 . https://web.archive.org/web/20140803030303/http://www.zdnet.com/microsoft-typescript-can-the-father-of-c-save-us-from-the-tyranny-of-javascript-7000005054/ . live.
  16. Web site: TypeStrong: The only TypeScript package you will ever need . . 21 July 2016 . 19 December 2018 . https://web.archive.org/web/20181219102240/https://github.com/TypeStrong/atom-typescript . live.
  17. Web site: Working with TypeScript in Visual Studio 2012 . 14 May 2013 . . Gastón . Hillar . 26 April 2015 . 29 September 2018 . https://web.archive.org/web/20180929115630/http://www.drdobbs.com/windows/working-with-typescript-in-visual-studio/240154792 . live.
  18. Web site: TypeScript 0.9 arrives with new compiler, support for generics . 18 June 2013 . . 26 April 2015 . 11 March 2018 . https://web.archive.org/web/20180311081207/https://www.theregister.co.uk/2013/06/18/typescript_update_0_9/ . live.
  19. Web site: TypeScript . Hejlsberg . Anders . Anders Hejlsberg . 2 April 2014 . Microsoft . . 26 April 2015 . 25 May 2015 . https://web.archive.org/web/20150525013836/http://channel9.msdn.com/Events/Build/2014/3-576 . live.
  20. Web site: Microsoft TypeScript graduates to Visual Studio . Joab . Jackson . 25 February 2014 . . . 26 April 2015 . 11 March 2016 . https://web.archive.org/web/20160311175558/http://www.pcworld.com/article/2101920/microsoft-typescript-graduates-to-visual-studio.html . live.
  21. Web site: New Compiler and Moving to GitHub . https://web.archive.org/web/20140722205833/http://blogs.msdn.com/b/typescript/archive/2014/07/21/new-compiler-and-moving-to-github.aspx . dead . 22 July 2014 . 21 July 2014 . Microsoft . TypeScript Language team blog . Jonathan . Turner . 26 April 2015.
  22. Web site: Peter. Bright. TypeScript, Microsoft's JavaScript for big applications, reaches version 2.0. Ars Technica. Condé Nast. 22 September 2016. 22 September 2016. 21 December 2018. https://web.archive.org/web/20181221125826/https://arstechnica.com/information-technology/2016/09/typescript-microsofts-javascript-for-big-applications-reaches-version-2-0/. live.
  23. Web site: Announcing TypeScript 3.0 . 30 July 2018 . 16 March 2020 . 30 May 2020 . https://web.archive.org/web/20200530031718/https://devblogs.microsoft.com/typescript/announcing-typescript-3-0/ . live.
  24. Web site: TypeScript 3.0 . 30 July 2018 . 16 March 2020 . 6 June 2020 . https://web.archive.org/web/20200606214433/https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html . live.
  25. Web site: 20 August 2020. Announcing TypeScript 4.0. 30 October 2020. TypeScript. en-US. 9 August 2024. https://web.archive.org/web/20240809080059/https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/. live.
  26. Web site: Documentation – TypeScript 5.0 . 18 May 2023 . www.typescriptlang.org . en . 9 August 2024 . https://web.archive.org/web/20240809080228/https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html . live.
  27. Web site: Hejlsberg . Anders . Anders Hejlsberg . 2025-03-11 . A 10x Faster TypeScript . 2025-03-11 . TypeScript . en-US.
  28. Web site: What is TypeScript and why with Anders Hejlsberg . Hejlsberg . Anders . Anders Hejlsberg . www.hanselminutes.com . 5 October 2012 . 15 January 2014 . 27 December 2018 . https://web.archive.org/web/20181227152425/https://www.hanselminutes.com/340/what-is-typescript-and-why-with-anders-hejlsberg . live.
  29. Web site: TypeScript: JavaScript Development at Application Scale . Somasegar . S. . msdn.com . 1 October 2012 . live . https://web.archive.org/web/20150422145537/http://blogs.msdn.com/b/somasegar/archive/2012/10/01/typescript-javascript-development-at-applicatio . 22 April 2015 . 27 November 2013.
  30. Web site: Documentation – TypeScript 5.2 . 9 November 2023 . www.typescriptlang.org . en . 9 August 2024 . https://web.archive.org/web/20240809080229/https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html . live.
  31. Web site: Welcome to TypeScript . 26 April 2015 . typescriptlang.org . . 10 March 2018 . https://web.archive.org/web/20180310153413/https://www.typescriptlang.org/ . live.
  32. Web site: Lawson . Darryl K. Taft, Loraine . 2025-03-12 . Go Power: Microsoft's Bold Bet on Faster TypeScript Tools . 2026-01-06 . The New Stack . en-US.
  33. Web site: Bloch . Olivier . Sublime Text, Vi, Emacs: TypeScript enabled! . . 1 October 2012 . 28 October 2012 . 29 October 2012 . https://web.archive.org/web/20121029094413/http://blogs.msdn.com/b/interoperability/archive/2012/10/01/sublime-text-vi-emacs-typescript-enabled.aspx . live.
  34. Web site: TypeScript support in WebStorm 6 . 27 February 2013 . JetBrains . 20 April 2013 . 2 June 2016 . https://web.archive.org/web/20160602072057/http://blog.jetbrains.com/webide/2013/02/typescript-support-in-webstorm-6/ . live.
  35. Web site: TypeScript support in ReSharper 8.1 . 28 October 2013 . JetBrains . 21 January 2014 . 2 February 2014 . https://web.archive.org/web/20140202124541/http://blog.jetbrains.com/dotnet/2013/10/28/typescript-support-resharper-81/ . live.
  36. Web site: ReSharper: The Visual Studio Extension for .NET Developers by JetBrains. JetBrains.
  37. Web site: atom-typescript. Atom. en. 9 January 2020. 4 October 2016. https://web.archive.org/web/20161004165736/https://atom.io/packages/atom-typescript. live.
  38. Web site: TypeStrong/grunt-ts . GitHub . 26 April 2015 . 16 April 2020 . https://web.archive.org/web/20200416143221/https://github.com/TypeStrong/grunt-ts . live.
  39. Web site: ppedregal/typescript-maven-plugin . GitHub . 26 April 2015 . 11 June 2018 . https://web.archive.org/web/20180611002148/https://github.com/ppedregal/typescript-maven-plugin . live.
  40. Web site: ivogabe/gulp-typescript . GitHub . 14 July 2017 . 11 June 2018 . https://web.archive.org/web/20180611024633/https://github.com/ivogabe/gulp-typescript . live.
  41. Web site: sothmann/typescript-gradle-plugin . GitHub . 26 April 2015 . 11 June 2018 . https://web.archive.org/web/20180611010933/https://github.com/sothmann/typescript-gradle-plugin . live.
  42. Web site: TSLint . palantir.github.io . 11 February 2019 . 21 December 2022 . https://web.archive.org/web/20221221214353/https://palantir.github.io/tslint/ . live.
  43. Web site: TSLint in 2019 . Palantir . 19 February 2019 . Medium . 24 April 2019.
  44. Web site: TSLint Deprecated to Focus Support on typescript-eslint . InfoQ . 24 April 2019 . 9 August 2024 . https://web.archive.org/web/20240809080105/https://www.infoq.com/news/2019/02/tslint-deprecated-eslint/ . live.