Modern TypeScript: A Practical Guide to Accelerate Your Development Velocity / Современный TypeScript: Практическое руководство по ускорению вашей разработки Год издания: 2023 Автор: Beattie-Hood Ben / Битти-Худ Бен Издательство: Apress Media ISBN: 978-1-4842-9723-0 Язык: Английский Формат: PDF Качество: Отсканированные страницы + слой распознанного текста Количество страниц: 304 Описание: Dive into the world of TypeScript, a popular superset of the jаvascript language that enhances the development experience with static typing. This book covers every aspect of TypeScript in a concise and easy-to-understand style, making it the ultimate resource for mastering TypeScript. Author Ben Beattie-Hood provides comprehensive coverage of TypeScript’s features, such as structural typing, optionality and union types, computed and recursive types, and much more. Each chapter is packed with practical, real-world examples and insider tips drawn from his 20 years of experience as a trainer, ensuring you understand the most important concepts and learn how to avoid common pitfalls. Modern TypeScript will put you on the path to becoming a TypeScript expert, help you greatly reduce errors, and boost your delivery velocity. Whether you’re building small projects or large-scale applications, this book will give you the skills and confidence to write cleaner, scalable, and more maintainable code. Don’t miss this opportunity to elevate your TypeScript proficiency and stay at the forefront of modern development. Окунитесь в мир TypeScript, популярного надмножества языка javascript, которое расширяет возможности разработки со статической типизацией. В этой книге в сжатой и понятной форме рассматриваются все аспекты TypeScript, что делает ее незаменимым ресурсом для освоения TypeScript. Автор Бен Битти-Худ всесторонне описывает возможности TypeScript, такие как структурная типизация, необязательность и типы объединений, вычисляемые и рекурсивные типы и многое другое. Каждая глава наполнена практическими примерами из реального мира и инсайдерскими советами, почерпнутыми из его 20-летнего опыта работы в качестве тренера, благодаря чему вы поймете наиболее важные концепции и узнаете, как избежать распространенных ошибок. Современный TypeScript поможет вам стать экспертом в области TypeScript, значительно сократит количество ошибок и повысит скорость доставки. Независимо от того, создаете ли вы небольшие проекты или крупномасштабные приложения, эта книга даст вам навыки и уверенность в написании более чистого, масштабируемого и удобного в обслуживании кода. Не упустите эту возможность повысить свой уровень владения TypeScript и оставаться на переднем крае современной разработки.
Примеры страниц
Оглавление
About the Author ................................................................................................... ix About the Technical Reviewer .................................................................................. xi Chapter 1: How Typescript Came to Be ..................................................................... 1 lntroduction ........................................................................................................... 1 History .................................................................................................................. 1 The Problem ........................................................................................................... 5 Scalable Velocity ..................................................................................................... 6 Testing Allows Scale ................................................................................................ 6 Docs Allow Scale ..................................................................................................... 7 Types Provide Both Testing and Docs ......................................................................... 7 Summary ............................................................................................................... 8 Chapter 2: Getting Started with the Developer Experience ............................................ 9 Introduction ........................................................................................................... 9 Environment and IDE ............................................................................................. 10 No-Frills Typescript Setup ....................................................................................... 10 Debugging Typescript ............................................................................................. 11 Typescript Within a More Realistic Setup ................................................................... 13 Honorable Mentions ............................................................................................... 15 Summary ............................................................................................................. 16 Chapter 3: Typescript Basics ................................................................................... 19 Introduction ......................................................................................................... 19 Structural Typing .................................................................................................. 20 JavaScript Types Are Structural Contracts ................................................................ 24 Adding Explicit Types to JavaScript .......................................................................... 25 Optionality ........................................................................................................... 31 All The Sugar ....................................................................................................... 33 Array and Object Destructuring, Spread, and Rest ..................................................... 33 Async ................................................................................................................. 37 Generators .......................................................................................................... 38 Inferred Types ..................................................................................................... 39 Types, Automagically ............................................................................................ 39 Type Widening and Narrowing ................................................................................ 43 Auto-narrowing, but Not Too Much .......................................................................... 45 Type Assertions .................................................................................................... 49 Compile-Time Assertions ........................................................................................ 50 Runtime Assertions ............................................................................................... 59 any and unknown Keywords ................................................................................... 65 Caution: Handle with Care ...................................................................................... 68 Parameterized Values ............................................................................................. 69 Index Signatures ................................................................................................... 71 Function Signatures ............................................................................................... 72 Constructor Signatures ........................................................................................... 74 A New Mental Model .............................................................................................. 75 Summary ............................................................................................................. 78 Chapter 4: Classes ................................................................................................ 81 Introduction ......................................................................................................... 81 Classes ................................................................................................................ 82 Constructors ........................................................................................................ 82 Access Modifiers ................................................................................................... 82 Fields .................................................................................................................. 83 Getters and Setters .............................................................................................. 86 Methods .............................................................................................................. 87 Inheritance .......................................................................................................... 87 Implements ......................................................................................................... 89 Static Modifier ..................................................................................................... 92 Warning 1: Classes Are Not Types .......................................................................... 93 Warning 2: Classes Can Cause Scope Bleed ............................................................ 95 Summary ........................................................................................................... 98 Chapter 5: Computed Types ................................................................................. 101 Introduction ....................................................................................................... 101 Type Aliases ...................................................................................................... 102 Using Type Aliases ............................................................................................. 105 Union Types ....................................................................................................... 107 Intersection Types ............................................................................................. 115 Generic Types ................................................................................................... 118 Type Parameters ............................................................................................... 118 con st Modifier on Generic Parameters ................................................................. 122 Generic Constraints .......................................................................................... 123 Inferred Type Keywords .................................................................................... 125 typeof Type Inference Keyword ......................................................................... 126 keyof Type Inference Keyword .......................................................................... 128 Where's the valueof Type Inference Keyword? .................................................... 131 Utility Types .................................................................................................. 132 Record ...................................................................................... 132 Pick< Type, Keys> ........................................................................................ 133 Omit ........................................................................................ 135 Partial< Type> ............................................................................................. 138 Required .......................................................................................... 139 Readonly ......................................................................................... 140 Exclude .................................................................................. 144 Extract ................................................................................... 147 Parameters ......................................................................... 147 ConstructorParameters ............................................................ 149 ReturnType ......................................................................... 150 Conditional Types ....................................................................................... 152 extends Keyword ........................................................................................ 153 infer Keyword ............................................................................................ 155 Extracting Inferred Types ............................................................................. 159 Distributive and Nondistributive Conditional Types ........................................... 161 Conditional Types via Property Accessors ......................................................... 163 Mapped Types .............................................................................................. 164 Changing the Type of Fields ............................................................................ 164 Adding and Removing Fields ............................................................................ 169 Renaming Fields .............................................................................................. 171 Recursive Types ................................................................................................ 172 Recursion Within an ObjectType ........................................................................... 172 Recursion over a Tuple Type ................................................................................ 174 Template Literals ................................................................................................ 177 Summary ........................................................................................................... 179 Chapter 6: Advanced Usage .................................................................................. 181 Introduction ....................................................................................................... 181 Expect and lsEqual .............................................................................................. 182 Compute ............................................................................................................ 185 JsonOf ............................................................................................................... 189 Flatten ............................................................................................................... 196 UrlParameters .................................................................................................... 198 Uri Parameters with Optional Pa rams .................................................................... 201 Further Reading .................................................................................................. 208 Summary ........................................................................................................... 209 Chapter 7: Performance ...................................................................................... 213 Introduction ..................................................................................................... 213 Reducing lnline Types ....................................................................................... 214 Reducing Inferred Types ................................................................................... 217 In line Caching Using Conditional Types ............................................................. 221 Reduce Intersections ....................................................................................... 223 Reduce Union Types ........................................................................................ 225 Partition Using Packages and Projects ............................................................... 225 Partitioning Using Packages ............................................................................. 225 Partitioning Using Projects ............................................................................... 226 Other Performance Tweaks ............................................................................... 228 Debugging Performance Issues .......................................................................... 228 Using the @typescript/analyze-trace NPM Package ................................................. 229 Using a Trace Viewer Within Your Browser ............................................................. 230 Summary ........................................................................................................... 231 Chapter B: Build .................................................................................................. 235 Introduction ....................................................................................................... 235 Compiler Options ............................................................................................... 236 Recommended tsconfig.json Settings .................................................................. 238 Other Options ................................................................................................. 246 Linting ........................................................................................................... 247 Installing ESLint. ............................................................................................ 247 Ideal Ruleset. ................................................................................................ 248 Additional Strict Errors ................................................................................... 253 Additional Strict Warnings .............................................................................. 257 Removed Rules ............................................................................................ 261 Further Rules ............................................................................................... 267 JSX/TSX ...................................................................................................... 267 Modules ...................................................................................................... 274 Module Types Explained ................................................................................ 274 Exports and Imports .................................................................................... 278 How Typescript Resolves Modules .................................................................. 282 Summary ................................................................................................... 286 Chapter 9: Wrap Up ..................................................................................... 289 Index ......................................................................................................... 291
Beattie-Hood Ben / Битти-Худ Бен - Modern TypeScript: A Practical Guide to Accelerate Your Development Velocity / Современный TypeScript: Практическое руководство по ускорению вашей разработки [2023, PDF, ENG] download torrent for free and without registration
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum