TypeScriptCompileBlocked

TypeScriptCompileBlocked If you are using a different build tool to build your project (e.g. gulp, grunt , etc.) and VS for the development and debugging experience, set <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> in your project. This should give you all the editing support, but not the build when you hit F5.

Optional Properties

Optional Properties Not all properties of an interface may be required. Some exist under certain conditions or may not be there at all. These optional properties are popular when creating patterns like “option bags” where you pass an object to a function that only has a couple of properties filled in. Here’s an example of this pattern: interface SquareConfig { color?: string; width?: number; } function createSquare(config: SquareConfig): {color: string; area: number} { let newSquare = {c

Publish to npm

Publish to npm The Publishing section explains how to publish your declaration files to an npm package, and shows how to manage your dependent packages.

Function declarations

Function declarations Destructuring also works in function declarations. For simple cases this is straightforward: type C = {a: string, b?: number} function f({a, b}: C): void { // ... } But specifying defaults is more common for parameters, and getting defaults right with destructuring can be tricky. First of all, you need to remember to put the type before the default value. function f({a, b} = {a: "", b: 0}): void { // ... } f(); // ok, default to {a: "", b: 0} Then, you need to rememb

Test

Test Run the project. You should see a message when you type in the input boxes:

Install typings for dependencies

Install typings for dependencies Angular 2 includes es6-shim for Promise support, but TypeScript still needs the types. Open a command prompt, then change directory to the app source: cd C:\Users\<you>\Documents\Visual Studio 2015\Projects\<app>\src\<app> npm install -g typings typings install --global dt~es6-shim

Test the resulting app

Test the resulting app gulp node dist/main.js The program should print “Hello from TypeScript!”.

Sections

Sections The guide is broken down into the following sections.

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.

&lt;reference no-default-lib=&quot;true&quot;/&gt;

/// <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"/>.