What is TypeScript?
Part of the Introduction To TypeScript section of Coddy's JavaScript journey — lesson 1 of 73.
TypeScript is a programming language developed by Microsoft that builds on JavaScript by adding static types. Think of it as JavaScript with an extra layer of safety and tooling.
The key concept to understand is that TypeScript is a superset of JavaScript. This means that any valid JavaScript code is also valid TypeScript code. You can take any existing JavaScript file, rename it from .js to .ts, and it will work in TypeScript.
What makes TypeScript special is that it adds type annotations on top of JavaScript. These annotations allow you to specify what kind of data your variables should hold - whether they're strings, numbers, objects, or other types. This helps catch potential errors before your code even runs.
// JavaScript (also valid TypeScript)
let message = "Hello World";
// TypeScript with type annotation
let message: string = "Hello World";TypeScript provides better development tools, improved code readability, and helps prevent common programming mistakes that might otherwise only be discovered when your application is running.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
Cheat sheet
TypeScript is a superset of JavaScript that adds static types. Any valid JavaScript code is also valid TypeScript code.
TypeScript adds type annotations to specify what kind of data variables should hold:
// JavaScript (also valid TypeScript)
let message = "Hello World";
// TypeScript with type annotation
let message: string = "Hello World";TypeScript files use the .ts extension instead of .js.
Try it yourself
This lesson doesn't include a code challenge.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Introduction To TypeScript
1Getting Started with TS
What is TypeScript?Why Use TypeScript?Your First TypeScript CodeCompilation Process & ErrorsRecap: Introduction to TS4Working with Functions
Typing Params & Return ValuesTyping Arrow FunctionsThe 'void' Return TypeOptional Parameters with '?'Default Parameter ValuesTyping Rest ParametersDefining Function TypesRecap: Building Typed Funcs2Core Types
Basic Types: str, num, booleanThe 'any' Type: Escape HatchThe 'unknown' TypeWorking with 'null' & 'undef'Type Inference in ActionExplicit Type AnnotationsRecap: Core Types Practice5Types: Aliases, Unions & Inter
Type Aliases for PrimitivesUnion Types ('|')Working with Union TypesLiteral TypesIntersection Types ('&')Combining Type AliasesRecap: Advanced Type Combos3Data Structure: Arrays & Tuple
Typed Arrays'readonly' Modifier for ArraysWhat is a Tuple?Declaring and Accessing TuplesDestructuring TuplesReadonly TuplesMulti-dimensional Typed Arrays Spread Operator with ArraysRecap: Arrays and Tuples