Install ASP.NET Core and TypeScript

Install ASP.NET Core and TypeScript First, install ASP.NET Core if you need it. This quick-start guide uses Visual Studio, which means that you’ll need Visual Studio 2015 in order to use ASP.NET Core. Next, if your version of Visual Studio does not already have TypeScript, you can install it for Visual Studio 2015.

Inheritance

Inheritance In TypeScript, we can use common object-oriented patterns. Of course, one of the most fundamental patterns in class-based programming is being able to extend existing classes to create new ones using inheritance. Let’s take a look at an example: class Animal { name: string; constructor(theName: string) { this.name = theName; } move(distanceInMeters: number = 0) { console.log(`${this.name} moved ${distanceInMeters}m.`); } } class Snake extends Animal { constructor(name

Install TypeScript

Install TypeScript If your version of Visual Studio does not already have TypeScript, you can install it for Visual Studio 2015 or Visual Studio 2013. This quickstart uses Visual Studio 2015.

Install our dependencies

Install our dependencies First ensure TypeScript, Typings, and webpack are installed globally. npm install -g typescript typings webpack Webpack is a tool that will bundle your code and optionally all of its dependencies into a single .js file. Typings is a package manager for grabbing definition files. Let’s now add React and React-DOM as dependencies to your package.json file: npm install --save react react-dom Next, we’ll add development-time dependencies on ts-loader and source-map-loader

Install our dependencies

Install our dependencies Now we can use npm install to install packages. First install TypeScript and gulp globally. (You might need to start npm install commands in this guide with sudo if you’re on a Unix system.) npm install -g typescript gulp-cli Then install gulp and gulp-typescript in your project’s dev dependencies. Gulp-typescript is a gulp plugin for Typescript. npm install --save-dev gulp gulp-typescript

Install our build dependencies

Install our build dependencies First ensure TypeScript and Typings are installed globally. npm install -g typescript typings You obviously know about TypeScript, but you might not know about Typings. Typings is a package manager for grabbing definition files. We’ll now use Typings to grab declaration files for Knockout: typings install --global --save dt~knockout The --global flag will tell Typings to grab any declaration files from DefinitelyTyped, a repository of community-authored .d.ts fi

Initialize the project

Initialize the project Now we’ll turn this folder into an npm package. npm init You’ll be given a series of prompts. You can use the defaults except for your entry point. For your entry point, use ./dist/bundle.js. You can always go back and change these in the package.json file that’s been generated for you.

Initialize the project

Initialize the project Now we’ll turn this folder into an npm package. npm init You’ll be given a series of prompts. You can use the defaults except for your entry point. For your entry point, use ./dist/main.js. You can always go back and change these in the package.json file that’s been generated for you.

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";

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