Static typing checks declared or inferred types before a program runs, helping catch incompatible assignments during compilation. TypeScript adds static types to JavaScript, then compiles TypeScript features into browser-executable JavaScript. section 2.3.1 section 3.4
A practical TypeScript data model uses types while retaining familiar JavaScript structure:
- Declare a task as a string and its completion state as a boolean. section 2.3.1
- Represent a collection with a TodoItem[] array and expose it as readonly TodoItem[]. section 2.3.1
- Use compilation to remove TypeScript-specific features before browser execution. section 2.3.1
Typed to-do item
export class TodoItem {\n constructor(public task: string, public complete: boolean = false) {}\n}\n\nThe constructor requires a string task and defaults complete to false, making the model's expected data explicit. 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
}
}
Inspect the complete TodoItem implementation, including its typed constructor parameters and default completion state. section 2.3.1











