Introduction

Anders Hejlsberg has a lot to answer for. Perhaps not as well known as Bjarne Stroustrup (C++) or Dennis Ritchie (C), he’s responsible for the creation of Turbo Pascal, Delphi, J++, and C#. And, as the creator of the language that the majority of .NET developers have been using for the past ten years, it is fair to say that he knows a fair bit about language design.

October 1, 2012 heralded the start of the journey for another Hejlsberg creation. TypeScript is a superset of JavaScript that brings to it an additional object-oriented-like syntax familiar to .NET programmers that compiles down into JavaScript that any browser can run today. As I write this three weeks since its announcement, it’s interesting to see how, with hindsight, the loudest reactions have been, “Why do we need this?” or “Not in my backyard,” and so on—the naysayers getting their dimes’ worth before this Friday, when Windows 8 is officially launched and they can copy and paste the same reactions back into their slightly revised pieces about the new touch interface that isn’t called Metro. Now that the dust has settled, my personal favorite response to all the initial negativity was simply, “But this is Anders.”

TypeScript is an interesting project, considering the forces that will work at it and the target at which it is aimed.

  • Its mission statement is “JavaScript for application-scale development.”
  • It’s an open source project, so there’s direct input from its users.
  • It’s a standard in its own right.
  • It’s a proof of concept for, and therefore will/should react to, parts of the ECMAScript 6 standard.

It’s inevitably a well-timed boost for the development of Windows 8 applications using HTML and JavaScript rather than C# and XAML, or a hybrid approach between the two for lack of JavaScript structure.

How TypeScript is allowed to evolve will be interesting. In the meantime, we have the initial v0.8.x releases that this book targets. It covers the following:

  • The language features in TypeScript additional to those in JavaScript
  • The tooling and community support for TypeScript development
  • How TypeScript can be included in ASP.NET, and Windows 8 application development projects

Who Is This Book For?

This book is for .NET and JavaScript developers who want to get a head start incorporating TypeScript into their applications. I explain the tools and language features you need to get up to speed quickly and also the current, soon to be ex-limitations of TypeScript as it makes its way toward a version 1.0 release.

What Do You Need to Know Before You Read This Book?

You need a good knowledge of an object-oriented language such as C#, ideally from creating ASP.NET web applications or Windows 8 applications. TypeScript tooling is, in the main, based on Visual Studio, so a familiarity with that would also be good.

You also need a basic familiarity with JavaScript, but advanced JavaScript skills are not necessary.

What Software Do You Need for This Book?

Technically, you don’t need anything more than a text editor such as Notepad to write TypeScript applications. However, to take full advantage of the tooling that exists, you’ll need a copy of a non-Express version of Visual Studio 2012. If you don’t have access to that, there is support for Visual Studio 2012 Express for Web and also for Sublime Text 2, Vim, and eMacs, which are all free downloads.

You’ll learn where to download and how to install TypeScript in Chapter 1.

What Is the Structure of the Book?

This is a primer to get you started on TypeScript. As TypeScript is at such an early stage in its adoption and development, this book does not aim to be a comprehensive tutorial and focuses instead on the three key topics that you’ll need to consider in order to determine whether you’ll want to start using TypeScript now, and if so, how to do it:

  • Chapter 1: Getting Up to Speed with TypeScript

    Just exactly what is TypeScript, and how does it fit in to your projects? In this chapter, you’ll look at the aims of TypeScript, how it compares to its perceived competition, and what exactly it does and does not do. You’ll also see how to install it, what you get, and how to run through creating a simple TypeScript-based page.
  • Chapter 2: The New Syntax

    TypeScript is all about the additional object-oriented-like syntax and features that it brings to JavaScript. In this chapter, you’ll look at the main new constructs in the language: static typing, classes, interfaces, arrow functions, and modules. You’ll see the similarities between them and their equivalents in C# as well as the common gotchas encountered so far.
  • Chapter 3: Working with TypeScript

    With the new syntax covered, the final chapter takes a look at how to incorporate TypeScript into your project. You’ll look at the various options on the TypeScript compiler, learn how to create declaration files for third-party JavaScript libraries, and see how to include TypeScript in your existing Visual Studio projects.
  • Appendix: Resources

    Finally, the appendix at the back lists all the code projects and the online communities that currently exist as well as the URLs mentioned in the book for a quick reference.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.171.153