Set up the server

Set up the server In project.json add another entry in "dependencies": "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final" The resulting dependencies should look like this: "dependencies": { "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final" }, Replace the body of Configure in Startup.cs with public void Configure(IApplicationBuilder app) { app.UseIISPlatformHandler(); ap

TypeScript 1.8

Type parameters as constraints With TypeScript 1.8 it becomes possible for a type parameter constraint to reference type parameters from the same type parameter list. Previously this was an error. This capability is usually referred to as F-Bounded Polymorphism. Example function assign<T extends U, U>(target: T, source: U): T { for (let id in source) { target[id] = source[id]; } return target; } let x = { a: 1, b: 2, c: 3, d: 4 }; assign(x, { b: 10, d: 20 }); assign(x, { e: 0 }

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/ | +- components/ | +- dist/ TypeScript files will start out in your src folder, run through the TypeScript compiler, then webpack, and end up in a bundle.js file in dist. Any components that we write will go in the src/components folder. Let’s scaffold

Object destructuring

Object destructuring You can also destructure objects: let o = { a: "foo", b: 12, c: "bar" } let {a, b} = o; This creates new variables a and b from o.a and o.b. Notice that you can skip c if you don’t need it. Like array destructuring, you can have assignment without declaration: ({a, b} = {a: "baz", b: 101}); Notice that we had to surround this statement with parentheses. JavaScript normally parses a { as the start of block.

species

Symbol.species A function valued property that is the constructor function that is used to create derived objects.

Function Types

Function Types Interfaces are capable of describing the wide range of shapes that JavaScript objects can take. In addition to describing an object with properties, interfaces are also capable of describing function types. To describe a function type with an interface, we give the interface a call signature. This is like a function declaration with only the parameter list and return type given. Each parameter in the parameter list requires both name and type. interface SearchFunc { (source: st

unscopables

Symbol.unscopables An Object whose own property names are property names that are excluded from the ‘with’ environment bindings of the associated objects.

Number

Number As in JavaScript, all numbers in TypeScript are floating point values. These floating point numbers get the type number. In addition to hexadecimal and decimal literals, TypeScript also supports binary and octal literals introduced in ECMAScript 2015. let decimal: number = 6; let hex: number = 0xf00d; let binary: number = 0b1010; let octal: number = 0o744;

Add NPM dependencies

Add NPM dependencies Add the following "dependencies" to package.json to install Angular 2 and SystemJS: "dependencies": { "angular2": "2.0.0-beta.11", "systemjs": "0.19.24", },

Iterables

Iterables An object is deemed iterable if it has an implementation for the Symbol.iterator property. Some built-in types like Array, Map, Set, String, Int32Array, Uint32Array, etc. have their Symbol.iterator property already implemented. Symbol.iterator function on an object is responsible for returning the list of values to iterate on.