liveBook · Manning

TypeScript

As explained in Pro Angular 16

TypeScript is a statically typed programming language that extends JavaScript with additional language features and compiles to JavaScript.

TypeScript is a superset of JavaScript that adds static types and other language features, then compiles into JavaScript that browsers can execute. Its type annotations make JavaScript development more predictable and familiar to developers from languages such as C# or Java. section 3.4 section 3.5

Angular applications use TypeScript as their primary language. The treatment focuses on the basic features needed for Angular development rather than offering a comprehensive language reference, continuing with more advanced features later. section 1.15 section 3.4

Core ideas include:

  • TypeScript specifies expected data types without changing JavaScript’s underlying type system. section 3.5
  • The compiler removes TypeScript features and produces browser-executable JavaScript. section 2.3.1
  • Modules organize dependencies between files through imports and exports. section 2.3.1
  • Classes and constructors support application data models, while Angular’s build process can translate newer JavaScript features for older browsers. section 2.3.1

A small TypeScript data model

A to-do application models an item with a string task and a Boolean completion state. A TodoList imports TodoItem, stores an array of items, exposes them as read-only, and adds new tasks by constructing TodoItem instances. section 2.3.1

Listing 2.7. The contents of the todoItem.ts file in the src/app folder
export class TodoItem {
 
  constructor(public task: string, public complete: boolean = false) {
      // no statements required
  }
}

View the complete TodoItem implementation, including its typed task and default completion value. section 2.3.1

How Pro Angular 16 covers it

How deep it goes
Explains the JavaScript relationship, static types, basic features, compilation, classes and modules, while stopping short of comprehensive coverage.
Examples
Uses a to-do data model with TodoItem and TodoList classes, typed properties, constructors, imports, exports and a read-only collection.
What it assumes
Assumes basic JavaScript familiarity while refreshing the relationship between JavaScript and TypeScript from the foundations.
What you can do after
Build Angular application code using basic TypeScript and understand how it becomes browser-executable JavaScript.
How it connects
Connects TypeScript with JavaScript, Angular, JavaScript modules, static types and browser execution.

Also explained in

Compare how 4 books explain TypeScript →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro Angular 16. The section links point to the parts of the book it draws on.