
Ultimate Typescript Handbook
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
This book provides a comprehensive guide to TypeScript, a programming language that extends JavaScript with powerful features like static typing, classes, and interfaces. The book is divided into thirteen chapters that cover everything from setting up a development environment to building an Angular app with TypeScript.
We start with an introduction to TypeScript and its benefits and go on to explain how TypeScript can help developers write more maintainable, scalable code and catch errors before they make it to production. The book then dives into more technical topics like basic type annotations, using the TypeScript compiler, advanced features like enums and interfaces, and manipulating types.
The book then discusses chapters on classes and control flow analysis that are particularly helpful for developers looking to build more complex applications. The book teaches by example, with numerous code examples that illustrate the main concepts and approaches towards writing TypeScript programs and codes, and finishes with a comprehensive practical example that shows step-by-step development of a modern web application using TypeScript and Angular.
TABLE OF CONTENTS
Chapter 1: Introduction to TypeScript and its Benefits
Chapter 2: Setting Up a Development Environment
Chapter 3: Basic Type Annotations
Chapter 4: Using the TypeScript Compiler
Chapter 5: Enums, Interfaces, and Namespaces
Chapter 6: Objects, Arrays, and Tuples in TypeScript
Chapter 7: Functions in TypeScript
Chapter 8: Classes in TypeScript
Chapter 9: Control Flow Analysis
Chapter 10: Manipulating Types
Chapter 11: TypeScript Modules
Chapter 12: Creating Declaration Files
Chapter 13: TypeScript Project: Creating an Angular App
More details
Content
- Cover Page
- Title Page
- Copyright Page
- Dedication Page
- About the Author
- Technical Reviewers
- Acknowledgements
- Preface
- Errata
- Table of Contents
- 1. Introduction to TypeScript and its Benefits
- Introduction
- Structure
- Introduction to TypeScript
- A short history of TypeScript
- Main components of TypeScript
- TypeScript's type system
- Advantages of using TypeScript
- Catching bugs
- Readability
- Refactoring
- Future language features
- Disadvantages of TypeScript
- The ways in which TypeScript prevents bugs
- Steps to begin using TypeScript
- Type-driven development
- Conclusion
- References
- 2. Setting up a Development Environment
- Introduction
- Structure
- Installing dependencies
- Version numbers
- Installing Node.js On Windows
- Installing Node.js on Mac
- Installing a code editor
- Installing TypeScript globally
- Creating a new TypeScript project
- The tsconfig.json file
- Installing TypeScript locally to a project
- Configuring TypeScript with tsconfig.json
- Default enabled configuration options
- target
- module
- esModuleInterop
- forceConsistentCasingInFileNames
- strict
- skipLibCheck
- Commonly used configuration options
- files
- include
- exclude
- baseUrl
- rootDir
- paths
- outDir
- resolveJsonModule
- Top-level configuration options
- Updating the project configuration
- Enabling TypeScript checking in JavaScript
- Default behavior
- Enabling type checking
- Adding JSDoc annotations
- Example project structure and use
- Conclusion
- References
- 3. Basic Type Annotations
- Introduction
- Structure
- Primitive types
- BigInt
- Boolean
- Number
- Null
- String
- Symbol
- Undefined
- The any type
- The unknown type
- The never type
- The as operator
- Down-casting
- Compound casting
- Older type-casting syntax
- Union types
- Literal types
- Literal union types
- Type aliases
- Type assertion
- Non-null assertion operator
- Conclusion
- References
- 4. Using the TypeScript Compiler
- Introduction
- Structure
- Compiling our TypeScript files
- Inspecting compiled files
- CLI flags
- --version
- --listFilesOnly
- --showConfig
- --help
- Using watch mode
- watchFile
- watchDirectory
- fallbackPolling
- synchronousWatchDirectory
- excludeDirectories
- excludeFiles
- assumeChangesOnlyAffectDirectDependencies
- Environment variables
- Building projects
- Build-specific flags
- Integrating with other build tools
- Integrating with webpack
- TypeScript webpack configuration
- Using third-party libraries
- Generating .d.ts files
- Generating d.ts files from .js files
- Conclusion
- References
- 5. Enums, Interfaces, and Namespaces
- Introduction
- Structure
- Interfaces
- Interface merging
- Extending interfaces
- Namespaces
- Namespace merging
- Enums
- Numeric enums
- Reverse mapping
- Exhaustiveness and the never type
- String enums
- Heterogeneous enums
- Computed and constant enums
- Literal enums
- Inlining enums
- Using the keyof operator
- Conclusion
- References
- 6. Objects, Arrays, and Tuples in TypeScript
- Introduction
- Structure
- Arrays
- Array type inference
- Read-only arrays
- Tuples
- Optional elements in tuples
- Rest elements in tuples
- Read-only tuples
- Object types
- Property modifiers
- Index signatures
- Intersections
- Generic object types
- Readonly utility type
- Conclusion
- References
- 7. Functions in TypeScript
- Introduction
- Structure
- Parameter Type and Return Type Annotations
- Type Inference for Functions
- Arrow Functions
- Type Inference for Arrow Functions
- Optional Parameters
- Rest Parameters
- Rest Arguments
- Destructured Parameters
- Void return type
- Function Type Expressions
- Call signatures
- Function Type Interfaces
- This Parameter
- Function overloads
- Overloading Arrow Functions
- Generator functions
- Generic functions
- Generic Function Constraints
- Conclusion
- References
- 8. Classes in TypeScript
- Introduction
- Structure
- Class Declarations
- Class Expressions
- Constructors
- Constructor Overloading
- Parameter Properties
- Access Modifiers
- Private Members in JavaScript
- Getters and Setters
- This Parameter
- Index Signatures
- Implementing an Interface
- Static Class Members
- Static Blocks
- Inheritance
- Abstract Classes
- Abstract Properties
- Abstract Methods
- Generic Classes
- Decorators
- TypeScript Design Patterns
- Conclusion
- References
- 9. Control Flow Analysis
- Introduction
- Structure
- Narrowing
- Widening
- Type Guards
- Truthiness Type Guards
- Narrowing with Typeof
- Handling null Values
- Narrowing with Instanceof
- Narrowing with the in Operator
- Narrowing with Type Predicates
- Discriminated Unions
- Assertion Functions
- Using as const
- Conclusion
- References
- 10. Manipulating Types
- Introduction
- Structure
- Generics
- Generic Interfaces
- Generic Types
- Generic Classes
- Generic Functions
- Conditional Types
- Indexed Access Types
- Mapped Types
- Adding and Removing Property Modifiers
- Remapping Property Keys
- Template Literal Types
- Capitalize
- Uncapitalize
- Uppercase
- Utility Types
- Awaited
- ConstructorParameters
- Exclude
- Extract
- InstanceType
- NonNullable
- Omit
- OmitThisParameter
- Partial
- Parameters
- Pick
- Readonly
- Record
- Required
- ReturnType
- ThisParameterType
- ThisType
- Conclusion
- References
- 11. TypeScript Modules
- Introduction
- Structure
- Modules in TypeScript
- Importing and exporting modules
- Type-only imports and exports
- Compiled modules
- Module-related configuration options
- Module
- Module resolution
- Base URL
- Paths
- Rootdirs
- Type roots
- Module suffixes
- Resolve JSON module
- Module resolution
- Compiler directives
- Reference path
- Reference types
- Reference lib
- No default lib
- AMD module
- AMD dependency
- Barrel files
- Nested barrels
- Augmenting modules
- Conclusion
- References
- 12. Creating Declaration Files
- Introduction
- Structure
- Creating declaration files
- Declaring global libraries
- Enhancing Intellisense with JSDoc
- Declaring global functions and variables
- Augmenting built-ins
- Declaring modular libraries
- Declaring default exports
- Declaring classes
- Declaring CommonJS modules
- Declaring UMD modules
- Publishing declarations
- Publishing with the library
- Publishing to Definitely Typed
- Testing types
- Conclusion
- References
- 13. Building a Conference App with Angular and TypeScript
- Introduction
- Structure
- Getting started
- Running build tasks
- Unit tests
- Linting
- Serving the application
- Creating the application shell
- Creating a data model
- Adding views
- Home view
- Adding routing
- Building the add-conference view
- Adding the conferences view
- Changing the default locale
- Adding a page not found component
- Handling data
- Unit testing
- Continuing with the example application
- Conclusion
- References
- Index
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.