TypeScript 1.6

JSX support JSX is an embeddable XML-like syntax. It is meant to be transformed into valid JavaScript, but the semantics of that transformation are implementation-specific. JSX came to popularity with the React library but has since seen other applications. TypeScript 1.6 supports embedding, type checking, and optionally compiling JSX directly into JavaScript. New .tsx file extension and as operator TypeScript 1.6 introduces a new .tsx file extension. This extension does two things: it enables

Update tsconfig.json

Update tsconfig.json Now that Angular 2 and its dependencies are installed, we need to enable TypeScript’s experimental support for decorators and include the es6-shim typings. In the future decorators and ES6 will be the default and these settings will not be needed. Add "experimentalDecorators": true, "emitDecoratorMetadata": true to the "compilerOptions" section, and add "../typings/index.d.ts" to the "files" section. Finally, we need to add a new entry in "files" for another file, "./model.

Dependencies on UMD libraries

Dependencies on UMD libraries

Templates

Templates In Templates you’ll find a number of declaration files that serve as a useful starting point when writing a new file. Refer to the documentation in Library Structures to figure out which template file to use.

Lay out the project

Lay out the project Let’s start out with a new directory. We’ll name it proj for now, but you can change it to whatever you want. mkdir proj cd proj To start, we’re going to structure our project in the following way: proj/ +- src/ +- built/ TypeScript files will start out in your src folder, run through the TypeScript compiler, and end up in built. Let’s scaffold this out: mkdir src mkdir built

<reference no-default-lib="true"/>

/// <reference no-default-lib="true"/> This directive marks a file as a default library. You will see this comment at the top of lib.d.ts and its different variants. This directive instructs the compiler to not include the default library (i.e. lib.d.ts) in the compilation. The impact here is similar to passing --noLib on the command line. Also note that when passing --skipDefaultLibCheck, the compiler will only skip checking files with /// <reference no-default-lib="true"/>.

Deep Dive

Deep Dive For seasoned authors interested in the underlying mechanics of how declaration files work, the Deep Dive section explains many advanced concepts in declaration writing, and shows how to leverage these concepts to create cleaner and more intuitive declaration files.

Private and protected members in classes

Private and protected members in classes Private and protected members in a class affect their compatibility. When an instance of a class is checked for compatibility, if the instance contains a private member, then the target type must also contain a private member that originated from the same class. Likewise, the same applies for an instance with a protected member. This allows a class to be assignment compatible with its super class, but not with classes from a different inheritance hierarc

for...of statements

for..of statements for..of loops over an iterable object, invoking the Symbol.iterator property on the object. Here is a simple for..of loop on an array: let someArray = [1, "string", false]; for (let entry of someArray) { console.log(entry); // 1, "string", false }

Sections

Sections The guide is broken down into the following sections.