Table of Contents
    Home / Definitions / TypeScript
    Languages 2 min read

    TypeScript is an open source programming language created by Microsoft. It is a superset of JavaScript, meaning it contains all of the functionality of JavaScript plus additional features. It is a strongly-typed, object-oriented, compiled language. Because it’s a superset, any program written in JavaScript will also run in TypeScript. It was created to allow for optional static type checking, which is valuable for developing large-scale applications. TypeScript is used to help catch mistakes early through a type system and make JavaScript development more efficient.

    Static type checking

    TypeScript uses static type checking, meaning that variables can be given a type when they are declared. The programming language will check types when it’s time to compile and throw an error if the variable is given a value of a different type. If there is an error, it does not prevent the code from executing; the code will still be compiled. Static type checking is optional, so if no type is given, the type will be set to any by default.

    JavaScript, in contrast, is dynamically typed. Variables can be reassigned or coerced into a value of a different type without warning, resulting in bugs that are easy to overlook if an application is large.

    TypeScript features

    • TypeScript starts and ends with JavaScript. It adopts the basic building blocks from JavaScript, meaning users who have experience with it won’t have to face a learning curve when using TypeScript. All TypeScript code is converted into the JavaScript equivalent for the purpose of execution. In addition, any valid .js file can be renamed to .ts and compiled with other TypeScript files.
    • Typescript supports JavaScript libraries, so all of the existing JavaScript frameworks, tools, and libraries can be reused.
    • TypeScript is portable across browsers, devices, and operating systems. It can run on any environment JavaScript runs on and doesn’t need a dedicated virtual machine or runtime environment to execute.