bootstraponline / async_await_typescript

:trident: ES7 async/await example using TypeScript & node v6 with Visual Studio Code 1.0
12 stars 3 forks source link

async/await with TypeScript

This example demonstrates the use of async/await using TypeScript v1.9-dev, Node.js v6 and Visual Studio Code v1.0;

$ node lib/await.js
1
2
3
Error: throw error to showcase source map support.
    at /async_await_typescript/lib/await.ts:21:9
    at undefined.next (native)
    at fulfilled (/async_await_typescript/lib/await.js:4:58)

Manually compile using gulp. To run tsc directly, use tsc -p .

Install dependencies

Visual Studio Code Integration

Directory Overview

.
├── .vscode
│   ├── launch.json
│   └── settings.json
├── lib
│   ├── await.js
│   └── await.js.map
├── node_modules
├── ts
│   └── await.ts
├── .gitignore
├── gulpfile.js
├── jsconfig.json
├── package.json
├── readme.md
├── tsconfig.json

Workflow

node --v8-options | grep "in progress"

Node lacks support for ES6 modules because v8 hasn't implemented them As a result module type commonjs is used in tsconfig.json.

TypeScript offers granular targeting via the lib compiler option specified in tsconfig.

Debugging

Visual Studio Code supports debugging TypeScript with source map support.

Credits