Book Image

TypeScript Essentials

By : Christopher Nance
Book Image

TypeScript Essentials

By: Christopher Nance

Overview of this book

Table of Contents (15 chapters)


This book is a quick and useful guide to learning the TypeScript language. The language features that TypeScript provides on top of JavaScript are covered thoroughly in this book with hands-on examples. TypeScript is a fairly new development language that can ease the pain of normal JavaScript development. Starting from downloading the compiler, covering language features, and implementing a dynamic application, this book will leave you ready to create new, large-scale JavaScript-based applications.

What this book covers

Chapter 1, Getting Started with TypeScript, covers setting up an environment for developing TypeScript applications and creating a simple application.

Chapter 2, TypeScript Basics, covers the primary language features that TypeScript creates on top of JavaScript and how each of these features compiles into plain JavaScript.

Chapter 3, The TypeScript Compiler, examines the TypeScript compiler and the different parameters that it accepts. The results of the different parameters will be discussed as well as how they affect the final JavaScript output.

Chapter 4, Object-oriented Programming with TypeScript, is all about the basics of object-oriented programming. You will be presented with the benefits that TypeScript adds to make ECMA Script a more full-fledged object-oriented language.

Chapter 5, Creating a Simple Drawing Application, walks you through creating a simple drawing application using the concepts already covered in the book. By the end of the chapter, you will have created a web-based drawing application that will give you a good understanding of writing complex applications using TypeScript.

Chapter 6, Declaration Files and Library Integrations, discusses declaration files and how they help us integrate with other JavaScript libraries. Libraries such as jQuery, KnockoutJS, and RequireJS will be covered.

Chapter 7, Enhancing the Drawing Application, re-examines the drawing application and shows you how to create a more reusable set of objects. Module definitions will be created and the process of minifying code is covered.

Chapter 8, Debugging TypeScript, discusses the different options available to debug TypeScript once it is deployed and running. We also cover unit testing and test-driven development, which will allow us to test functionality with code.

What you need for this book

TypeScript has a standalone compiler install, so any text editor can be used to develop TypeScript applications. The examples provided with this book will use Microsoft's Visual Studio, and it is recommended that you use it too to help you follow the examples; however, this is not a requirement. A basic understanding of JavaScript and web development is required as not every language construct will be covered; just the ones that TypeScript provides on top of it.

Who this book is for

This book is intended to introduce the TypeScript language and its features to anyone looking to develop rich web applications. Whether you are new to web development or are an experienced engineer with strong JavaScript skills, this book will get you writing code quickly. A basic understanding of JavaScript and its language features is necessary for this book.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "To get started, let's create a new file on the filesystem and call it HelloWorld.ts."

A block of code is set as follows:

var p = document.createElement('p');
var hello: string = "Hello";
var world: string = 2;
p.textContent = hello + " " + world;


Any command-line input or output is written as follows:

tsc HelloWorld.ts

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "To create a new project that includes TypeScript, go to the File menu and navigate to New | Project."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.