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.

Library Structures

Library Structures The Library Structures guide helps you understand common library formats and how to write a correct declaration file for each format. If you’re editing an existing file, you probably don’t need to read this section. Authors of new declaration files must read this section to properly understand how the format of the library influences the writing of the declaration file.

Add a TypeScript configuration file

Add a TypeScript configuration file You’ll want to bring your TypeScript files together - both the code you’ll be writing as well as any necessary declaration files. To do this, you’ll need to create a tsconfig.json which contains a list of your input files as well as all your compilation settings. Simply create a new file in your project root named tsconfig.json and fill it with the following contents: { "compilerOptions": { "outDir": "./dist/", "sourceMap": true, "noImplicitAny"

Add a TypeScript configuration file

Add a TypeScript configuration file You’ll want to bring your TypeScript files together - both the code you’ll be writing as well as any necessary declaration files. To do this, you’ll need to create a tsconfig.json which contains a list of your input files as well as all your compilation settings. Simply create a new file in your project root named tsconfig.json and fill it with the following contents: { "compilerOptions": { "outDir": "./built/", "sourceMap": true, "noImplicitAny

Mappings

Mappings Compiler Option MSBuild Property Name Allowed Values --allowJs Not supported in MSBuild --allowSyntheticDefaultImports TypeScriptAllowSyntheticDefaultImports boolean --allowUnreachableCode TypeScriptAllowUnreachableCode boolean --allowUnusedLabels TypeScriptAllowUnusedLabels boolean --baseUrl TypeScriptBaseUrl File path --charset TypeScriptCharset --declaration TypeScriptGeneratesDeclarations boolean --declarationDir TypeScriptDeclarationDir File path --diagnostics Not supported in

Compiler Options

Compiler Options Option Type Default Description --allowJs boolean true Allow JavaScript files to be compiled. --allowSyntheticDefaultImports boolean module === "system" Allow default imports from modules with no default export. This does not affect code emit, just typechecking. --allowUnreachableCode boolean false Do not report errors on unreachable code. --allowUnusedLabels boolean false Do not report errors on unused labels. --baseUrl string Base directory to resolve non-relative module na

Modular Libraries

Modular Libraries Some libraries only work in a module loader environment. For example, because express only works in Node.js and must be loaded using the CommonJS require function. ECMAScript 2015 (also known as ES2015, ECMAScript 6, and ES6), CommonJS, and RequireJS have similar notions of importing a module. In JavaScript CommonJS (Node.js), for example, you would write var fs = require("fs"); In TypeScript or ES6, the import keyword serves the same purpose: import fs = require("fs"); You’

Write an HTML page

Write an HTML page Add a New Item named index.html inside wwwroot. Use the following code for index.html: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <script src="scripts/app.js"></script> <title></title> </head> <body> <div id="message"></div> <div> Compiler: <input id="compiler" value="TypeScript" onkeyup="document.getElementById('message').innerText = sayHello()" /><br /> Fr

Set up the build

Set up the build

Type assertions

Type assertions Sometimes you’ll end up in a situation where you’ll know more about a value than TypeScript does. Usually this will happen when you know the type of some entity could be more specific than its current type. Type assertions are a way to tell the compiler “trust me, I know what I’m doing.” A type assertion is like a type cast in other languages, but performs no special checking or restructuring of data. It has no runtime impact, and is used purely by the compiler. TypeScript assum