Book description
Exploit the features of TypeScript to easily create your very own web applications
About This Book- Develop modular, scalable, maintainable, and adaptable web applications by taking advantage of TypeScript
- Walk through the fundamentals of TypeScript with the help of practical examples
- Enhance your web development skills using TypeScript 2.x
If you are a developer aiming to learn TypeScript to build attractive web applications, this book is for you. No prior knowledge of TypeScript is required. However, a basic understanding of JavaScript would be an added advantage.
What You Will Learn- Understand TypeScript in depth, including its runtime and advanced type system features
- Master the core principles of the object-oriented programming and functional programming paradigms with TypeScript
- Save time using automation tools such as Gulp, Webpack, ts-node, and npm scripts
- Develop robust, modular, scalable, maintainable, and adaptable applications with testing frameworks such as Mocha, Chai, and Sinon.JS
- Put your TypeScript skills to practice by developing full-stack web applications with Node.js, React and Angular
- Use the APIs of the TypeScript compiler to build custom code analysis tool
TypeScript is an open source and cross-platform statically typed superset of JavaScript that compiles to plain JavaScript and runs in any browser or host.
This book is a step-by-step guide that will take you through the use and benefits of TypeScript with the help of practical examples. You will start off by understanding the basics as well as the new features of TypeScript 2.x. Then, you will learn how to work with functions and asynchronous programming APIs. You will continue by learning how to resolve runtime issues and how to implement TypeScript applications using the Object-oriented programming (OOP) and functional programming (FP) paradigms. Later, you will automate your development workflow with the help of tools such as Webpack. Towards the end of this book, you will delve into some real-world scenarios by implementing some full-stack TypeScript applications with Node.js, React and Angular as well as how to optimize and test them. Finally, you will be introduced to the internal APIs of the TypeScript compiler, and you will learn how to create custom code analysis tools.
Style and approachThis is a step-by-step guide that covers the fundamentals of TypeScript with practical examples.
Table of contents
- Title Page
- Copyright and Credits
- Dedication
- Packt Upsell
- Contributors
- Preface
-
Introducing TypeScript
- The TypeScript architecture
-
TypeScript language features
- Types
- Variables, basic types, and operators
-
Flow control statements
- The single-selection structure (if)
- The double-selection structure (if...else)
- The inline ternary operator (?)
- The multiple-selection structure (switch)
- The expression is tested at the top of the loop (while)
- The expression is tested at the bottom of the loop (do...while)
- Iterate on each object's properties (for...in)
- Iterate values in an iterable (for...of)
- Counter-controlled repetition (for)
- Functions
- Classes
- Interfaces
- Namespaces
- Putting everything together
- Summary
- Working with Types
-
Working with Functions
-
Working with functions in TypeScript
- Function declarations and function expressions
- Function types
- Trailing commas in function arguments
- Functions with optional parameters
- Functions with default parameters
- Functions with REST parameters
- Function overloading
- Specialized overloading signature
- Function scope
- Immediately invoked functions
- Tag functions and tagged templates
- Asynchronous programming in TypeScript
- Summary
-
Working with functions in TypeScript
-
Object-Oriented Programming with TypeScript
- Classes
- Abstract classes
- Interfaces
- SOLID principles, encapsulation, and polymorphism
- Summary
-
Working with Dependencies
- Third-party dependencies
- Internal modules (module and namespace)
-
External modules
- Module loaders and module definition syntaxes
- External modules at design time and runtime
- ES6 modules (runtime and design time)
- Legacy external modules (design time only)
- AMD modules (runtime only)
- CommonJS modules (runtime only)
- UMD modules (runtime only)
- SystemJS modules (runtime only)
- Modules summary
- Managing dependencies in OOP
- Summary
- Understanding the Runtime
- Functional Programming with TypeScript
- Working with Decorators
-
Automating Your Development Workflow
- A modern development workflow
- Prerequisites
- Source control tools
- Package management tools
- The TypeScript compiler
- Linting tools
- Working with npm scripts
- Gulp
- Webpack
- Webpack development server
- Unit testing and test coverage
- Visual Studio Code
- ts-node
- Continuous integration (CI) tools
- Scaffolding tools
- Why does the command line win?
- Summary
- Node.js Development with TypeScript
- Frontend Development with React and TypeScript
-
Frontend Development with Angular and TypeScript
- Working with Angular
- About the sample application
- Serving an Angular application with Node.js
- Bootstrapping an Angular application
- Working with NgModules
-
Working with Angular components
- Our first component
- Components and directives
- Data binding
- Working with @Attribute and @Input
- Using structural directives
- Using the <ng-content> directive
- Working with @Output and EventEmitter
- Working with the component's host
- Working with the Angular router
- Angular component life cycle hooks
- Working with services
- Smart components and dumb components
- Dependency injection in Angular
- Summary
- Application Performance
- Application Testing
- Working with the TypeScript Compiler and the Language Services
- Other Books You May Enjoy
Product information
- Title: Learning TypeScript 2.x - Second Edition
- Author(s):
- Release date: April 2018
- Publisher(s): Packt Publishing
- ISBN: 9781788391474
You might also like
video
TypeScript for Beginners
TypeScript makes the life of developers easy by simplifying code. It follows programming conventions that make …
book
Learn TypeScript 3 by Building Web Applications
Learn TypeScript and many of its features by building state of art web applications from scratch …
book
Mastering TypeScript 3 - Third Edition
Master the TypeScript language and its latest features. Explore modern application frameworks and utilize industry best …
book
Essential TypeScript: From Beginner to Pro
Work with Typescript and get the most from this versatile open source language. Author Adam Freeman …