Book Image

Mastering TypeScript - Second Edition

By : Nathan Rozentals
Book Image

Mastering TypeScript - Second Edition

By: Nathan Rozentals

Overview of this book

<p>The TypeScript language, compiler, and opensource development toolset brings JavaScript development up to the enterprise level. It allows us to use ES5, ES6, and ES7 JavaScript language features today, including classes, interfaces, generics, modules, and more. Its simple typing syntax enables building large, robust applications using object-oriented techniques and industry standard design principles.</p> <p>Packed with practical, real-world examples, this book is a guide to bringing the benefits of strongly typed, object-oriented programming and design principles into the JavaScript development space. Starting with core language features, and working through more advanced topics such as generics and asynchronous programming techniques, you will learn how to gain maximum benefit from your JavaScript development with TypeScript. With a strong focus on test-driven development, and coverage of many popular and in-demand JavaScript frameworks, you can fast-track your TypeScript knowledge to a professional level. By the end of this book, you will be able to confidently build TypeScript applications, whether you are targeting Angular, Aurelia, React, Backbone, Node, or any other JavaScript framework.</p>
Table of Contents (21 chapters)
Mastering TypeScript - Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
Free Chapter
1
TypeScript - Tools and Framework Options

Modular code


Our application so far has all of its HTML, CSS, and business logic as part of the AppComponent class. Although we have already broken this class down into a separate app.component.html and app.component.css files, it really contains a number of separate components all in one. Let's take this opportunity to modularize our code, and create three separate classes. These will be:

  • A NavbarComponent class to render and handle the navigation bar at the top of the screen

  • A SideNavComponent class to render the left-hand side navigation panel

  • A RightScreenComponent to handle the detail panel that slides in from the right

This means that the AppComponent class becomes the central application class, and it will be responsible for coordinating each of these components.

Navbar component

Our first task is to create a NavbarComponent class that will have the sole responsibility of rendering the navigation bar at the top of the screen. To do this we will create a navbar.component.ts file and a navbar...