Typescript Step by Step
  • Introduction
  • Types
  • Interface
  • Class
  • Module
  • Function
  • What Next?
Powered by GitBook
On this page
  • References
  • Install Typescript
  • Using Typescript
  • Typescript compiltation with Sublime Text 3
  • Typescript compiltation with Webpack

Was this helpful?

Introduction

NextTypes

Last updated 4 years ago

Was this helpful?

  • Superset of Javascript

  • Compiles to plain JavaScript

  • Strongly Typed

  • Class based Object-Oriantation

References

Handbook -

Playground -

Typescript Demo with Webpack -

Install Typescript

// Install node js 1st
npm install typescript -g

Using Typescript

// just simple
tsc test.ts

// watch changes
tsc test.ts -w

// change output filename
tsc myfile.ts myoutput.js

// compile multiple ts file in one shot
tsc a.ts b.ts --out myoutput.js

Typescript compiltation with Sublime Text 3

install TypeScript plugin using sublime package manager. use Ctrl + B to compile typescript file.

it also help in code completion...

Also you want to install sublime text 3 tslint to get immediate error notification.

Typescript compiltation with Webpack

npm install ts-loader --save-dev

in webpack.config.js include ts-loader ...

module.exports = {  
  entry: './app.ts',
  output: {
    filename: 'bundle.js'
  },
  resolve: {
    extensions: ['', '.webpack.js', '.web.js', '.ts', '.js']
  },
  module: {
    loaders: [
      { test: /\.ts$/, loader: 'ts-loader' }
    ]
  }
}

now we can use typescript like below...

require('../tssample/test.js');
or
require('../tssample/test.ts');
http://www.typescriptlang.org/Handbook
http://www.typescriptlang.org/Playground
https://github.com/hesing/typescript-webpack-demo
ts build
code completion