Import a single export from a module

Import a single export from a module import { ZipCodeValidator } from "./ZipCodeValidator"; let myValidator = new ZipCodeValidator(); imports can also be renamed import { ZipCodeValidator as ZCV } from "./ZipCodeValidator"; let myValidator = new ZCV();

Import a module for side-effects only

Import a module for side-effects only Though not recommended practice, some modules set up some global state that can be used by other modules. These modules may not have any exports, or the consumer is not interested in any of their exports. To import these modules, use: import "./my-module.js";

Import

Import Importing is just about as easy as exporting from a module. Importing an exported declaration is done through using one of the import forms below:

Identifying Kinds of Libraries

Identifying Kinds of Libraries First, we’ll review the kinds of libraries TypeScript declaration files can represent. We’ll briefly show how each kind of library is used, how it is written, and list some example libraries from the real world. Identifying the structure of a library is the first step in writing its declaration file. We’ll give hints on how to identify structure both based on its usage and its code. Depending on the library’s documentation and organization, one might be easier tha

Hybrid Types

Hybrid Types As we mentioned earlier, interfaces can describe the rich types present in real world JavaScript. Because of JavaScript’s dynamic and flexible nature, you may occasionally encounter an object that works as a combination of some of the types described above. One such example is an object that acts as both a function and an object, with additional properties: interface Counter { (start: number): string; interval: number; reset(): void; } function getCounter(): Counter { let

hasInstance

Symbol.hasInstance A method that determines if a constructor object recognizes an object as one of the constructor’s instances. Called by the semantics of the instanceof operator.

gulp

gulp

Gulp

Gulp If you’re using Gulp in some fashion, we have a tutorial on using Gulp with TypeScript, and integrating with common build tools like Browserify, Babelify, and Uglify. You can read more there.

Grunt

Grunt

Grab our runtime dependencies

Grab our runtime dependencies We’ll need to grab Knockout itself, as well as something called RequireJS. RequireJS is a library that enables us to load modules at runtime asynchronously. There are several ways we can go about this: Download the files manually and host them. Download the files through a package manager like Bower and host them. Use a Content Delivery Network (CDN) to host both files. We’ll keep it simple and go with the first option, but Knockout’s documentation has details on