Mastering TypeScript 3
Build enterprise-ready, industrial-strength web applications using TypeScript 3 and modern frameworks, 3rd Edition
Nathan Rozentals
- 694 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Mastering TypeScript 3
Build enterprise-ready, industrial-strength web applications using TypeScript 3 and modern frameworks, 3rd Edition
Nathan Rozentals
About This Book
Master the TypeScript language and its latest features. Explore modern application frameworks and utilize industry best practices in TDD, OOP and UI Design.
Key Features
- Learn the key features of TypeScript 3 and explore advanced language features through in-depth discussions.
- Use TypeScript with modern frameworks including Backbone, Angular, Aurelia, React, and Node.
- Explore TDD practices, OOP techniques, and industry best practices to create high-quality, modular, and adaptable applications.
Book Description
TypeScript is both a language and a set of tools to generate JavaScript. It was designed by Anders Hejlsberg at Microsoft to help developers write enterprise-scale JavaScript.
Starting with an introduction to the TypeScript language, before moving on to basic concepts, each section builds on previous knowledge in an incremental and easy-to-understand way. Advanced and powerful language features are all covered, including asynchronous programming techniques, decorators, and generics.
This book explores many modern JavaScript and TypeScript frameworks side by side in order for the reader to learn their respective strengths and weaknesses. It will also thoroughly explore unit and integration testing for each framework.
Best-of-breed applications utilize well-known design patterns in order to be scalable, maintainable, and testable. This book explores some of these object-oriented techniques and patterns, and shows real-world implementations.
By the end of the book, you will have built a comprehensive, end-to-end web application to show how TypeScript language features, design patterns, and industry best practices can be brought together in a real-world scenario.
What you will learn
- Gain insights into core and advanced TypeScript language features
- Integrate existing JavaScript libraries and third-party frameworks using declaration files
- Target popular JavaScript frameworks, such as Angular, React, and more
- Create test suites for your application with Jasmine and Selenium
- Organize your application code using modules, AMD loaders, and SystemJS
- Explore advanced object-oriented design principles
- Compare the various MVC implementations in Aurelia, Angular, React, and more
Who this book is for
This guide to the TypeScript that starts with basic concepts, and then builds on this knowledge to introduce more advanced language features and frameworks. No prior knowledge of JavaScript is required, although some prior programming experience is assumed. If you are keen to learn TypeScript, this book will give you all of the necessary knowledge and skills to tackle any TypeScript project. If you are already an experienced JavaScript or TypeScript developer, then this book will take your skills to the next level. Learn how to use TypeScript with a multitude of modern frameworks, and choose the best framework for your project requirements. Investigate techniques for Test Driven Development, explore industry-standard design patterns, and learn how to put together a full production-ready TypeScript application.
Frequently asked questions
Information
Types, Variables, and Function Techniques
- Basic types and type syntaxâstrings, numbers, and booleans
- Inferred typing and duck typing
- Template strings
- Arrays, and using for...in and for...of
- The any type and explicit casting
- Enums
- The const and let keywords
- Definite assignment and dotted property types
- Functions and anonymous functions
- Function parameters
- Function callbacks, function signatures, and function overrides
- Try catch
- Advanced types, including union types, type guards, and type aliases
- The never and unknown types
- Object rest and spread
- Tuples
- Bigint
Basic types
JavaScript typing
function doCalculation(a,b,c) { return (a * b) + c; } var result = doCalculation(2,3,1); console.log('doCalculation():' + result);
doCalculation():7
result = doCalculation("2","3","1"); console.log('doCalculation():' + result);
doCalculation():61
TypeScript typing
Type syntax
function doCalculation( a : number, b : number, c : number) { return ( a * b ) + c; } var result = doCalculation(3,2,1); console.log("doCalculation():" + result);
var result = doCalculation("1", "2", "3"); console.log("doCalculation():"" + result);
error TS2345: Argument of type '"1"' is not assignable to parameter of type 'number'.
var myString : string; var myNumber : number; var myBoolean : boolean; myString = "1"; myNumber = 1; myBoolean = true;
myString = myNumber; myBoolean = myString; myNumber = myBoolean;
- The first error is generated because we cannot assign a number value to a variable of type string
- Similarly, the second compile error indicates that we cannot assign a string value to a variable of type boolean
- And the third error is generated because we cannot assign a boolean value to a variable of type number
myString = myNumber.toString(); myBoolean = (myString === "test"); if (myBoolean) { myNumber = 1; }