Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Yakov Fain, Anton Moiseev

Rating No ratings yet

TypeScript is JavaScript with an important upgrade! By adding a strong type system to JavaScript, TypeScript can help you eliminate entire categories of runtime errors. In TypeScript Quickly, you’ll learn to build rock-solid apps through practical examples and hands-on projects under the expert instruction of experienced web developers Yakov Fain and Anton Moiseev. About the technology Strong typing can eliminate nearly all errors caused by unanticipated data values. With TypeScript, an enhanced version of JavaScript, you can specify types and type annotations so your code is easier to read and far less likely to fail at runtime. And because the core of TypeScript is standard JavaScript, it runs on all major browsers and can be used with frameworks like Angular, Vue, and React. About the book TypeScript Quickly teaches you to exploit the benefits of types in browser-based and standalone applications. In this practical guide, you’ll build a fascinating blockchain service app that takes you through a range of type-sensitive programming techniques. As you go, you’ll also pick up valuable techniques for object-oriented programming with classes, interfaces, and advanced features such as decorators and conditional types. What's inside • Mastering TypeScript syntax • Using TypeScript with JavaScript libraries • Tooling with Babel and Webpack • Developing TypeScript apps using Angular, React, and Vue About the reader For web developers comfortable with JavaScript and HTML. About the author Yakov Fain and Anton Moiseev are experienced web developers. They have authored two editions of Manning’s Angular Development with TypeScript.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# TypeScript Quickly — Reading Guide ## 【One-Line Pitch】 A practical, project-driven introduction to TypeScript for JavaScript developers who want to eliminate runtime errors through strong typing, covering everything from basic syntax to advanced type manipulation and popular framework integration. If you're comfortable with JavaScript and want to write more reliable, maintainable code, this book is your hands-on path to TypeScript mastery. ## 【Book Arc】 - **Opening (~0%–9%)**: Sets up the value proposition of TypeScript—why strong typing eliminates entire categories of runtime errors—and walks through installation, the TypeScript compiler (tsc), and compiling your first typed program. Includes a simple example showing how type mismatches are caught at compile time rather than runtime. - **Early (~9%–25%)**: Covers variable declarations with types, the type system's fundamentals (including union types and the `never` type), and introduces TypeScript's structural type system—a key difference from Java-style nominal typing. Transitions into object-oriented programming with classes, inheritance, access modifiers, and the `super` keyword. - **Early–Middle (~25%–38%)**: Explores interfaces, method overloading, and the "program to interfaces" philosophy. Introduces generics with practical examples like a `Comparator<T>` interface that prevents type-unsafe comparisons, plus enums and higher-order functions with enforced return types. - **Middle (~38%–47%)**: Dives into advanced type manipulation—mapped types like `Readonly<T>`, custom mapped types (e.g., `Modifiable<T>` that removes `readonly` modifiers), conditional types with the `infer` keyword, and utility types like `Promisify<T>` that wrap function returns in Promises. - **Late (~47%–end)**: Moves into tooling and real-world application—code quality tools like TSLint, and building a blockchain service app that ties together type-sensitive programming techniques. The book's final chapters cover integrating TypeScript with Angular, React, and Vue, plus module bundling with Webpack and Babel. ## 【Key Takeaways】 - **TypeScript catches type errors at compile time, not runtime** (Opening): Declaring variable types means the compiler flags mismatches like assigning a string to a number variable during development—saving debugging time and preventing entire categories of production bugs. - **TypeScript uses a structural type system** (Early): Unlike Java, where class names must match, TypeScript considers types compatible if their structures match—so a `Person` instance can be assigned to a `Customer` variable if both have the same shape. This is more flexible but requires understanding shape-based compatibility. - **Union types and the `never` type eliminate impossible code paths** (Early): When a parameter is typed as `string | number`, the type checker knows an `else` branch handling other types is unreachable—inferred as `never`—helping you write exhaustive, safer conditionals. - **Interfaces are the foundation of maintainable APIs** (Early): "Program to interfaces" means declaring method signatures upfront (e.g., `IProductService`) before implementing them—the compiler enforces that implementations match, preventing forgotten methods or signature mistakes. - **Generics constrain types without losing flexibility** (Early): Using `Comparator<T>` instead of `Comparator` with `any` means `Rectangle.compareTo()` only accepts `Rectangle` parameters—catching type mismatches at compile time that would otherwise cause runtime errors. - **Mapped types transform existing types systematically** (Middle): Built-in types like `Readonly<T>` make all properties read-only, and you can create custom ones like `Modifiable<T>` (using `-readonly`) to remove modifiers—powerful for type-level transformations without rewriting interfaces. - **Conditional types with `infer` enable sophisticated type logic** (Middle): Types like `ReturnPromise<T>` check if a type is a function, extract its return type via `infer R`, and wrap it in a Promise—preserving type information that would be lost with `any`. ## 【Reading Tips】 - **Skim the opening setup if you're already using Node.js**—the installation and first-compile sections are straightforward; focus instead on the type system examples that follow. - **Deep-read the structural type system and interface sections**—these are the most conceptually important parts for JavaScript developers new to TypeScript's type philosophy, and they underpin everything later in the book. - **Work through the generics and advanced type examples in the TypeScript Playground**—the book references playground URLs throughout; actively experimenting with mapped types and conditional types is far more effective than passive reading. - **Pay attention to the blockchain project chapters** (referenced from ~47% onward)—this is where the book's practical payoff happens, showing how all the type techniques combine in a real application. If you're short on time, prioritize this over the framework-specific chapters. - **The tooling chapter (TSLint, Webpack, Babel) can be skimmed initially**—return to it when you're setting up a real project and need configuration guidance. ## 【Coverage Limits】 This guide covers the book's progression through TypeScript fundamentals, OOP, generics, advanced types, and tooling setup. The excerpts do not cover the detailed blockchain project implementation or the Angular/React/Vue integration chapters in depth—those sections are referenced but not excerpted in the source material. ##
Excerpt 1
presentation components 416 appendix Modern JavaScript 423 index 459 about the cover illustration The figure on the cover of TypeScript Quickly is captioned...
View in text
Excerpt 2
as long as the shape of the object literal is the same. The following listing will compile without errors. Listing 2.19 Compatible types class Person { name:...
View in text
Excerpt 3
rvice implements IProductService { Implements the interface getProducts(): Product[]{ // the code for getting products // from a real data source goes here r...
View in text
Excerpt 4
ormation for function arguments as well as the return type. Let’s assume that a generic type R represents the return type of the function. Then we can use th...
View in text
Excerpt 5
e documentation at https://babeljs.io/docs/en/babel-plugin- transform-typescript (for example, it doesn’t support const enum). For better TypeScript support,...
View in text
Excerpt 6
lock” and “Second block” respectively. The genesis block is created in the constructor of Blockchain. 198 CHAPTER 9 Developing a browser-based blockchain nod...
View in text
Excerpt 7
roject structure, its configuration files, and npm scripts. The WebSocket protocol—what it’s about and why it’s better than HTTP for implementing a notificat...
View in text
Excerpt 8
us to run both HTTP and WebSocket servers on the same port. Finally, we instantiate the BlockchainServer TypeScript class, which uses WebSockets. Its code is...
View in text
Tags
AI categories
TypeScriptProgramming LanguageWeb Technology
ISBN: 1617295949
Publish Year: 2020
Language: English
Pages: 487
File Format: PDF
File Size: 8.8 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…