main.ts
import {Promise} from 'es6-promise';
const p: Promise<string> = new Promise (
(resolve: (str: string)=>void, reject: (str: string)=>void) => {
const a: string = "hello from Promise";
resolve(a);
}
);
p.then((st) => {
console.log(st);
});
tsconfig.json
{
"compilerOptions": {
"target": "es3",
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"noLib": false
},
"filesGlob": [
"./**/*.ts",
"!./node_modules/**/*.ts"
],
"files": [
"./main.ts",
"./typings/es6-promise/es6-promise.d.ts"
]
}
compileandrun.sh
#!/bin/sh
npm install es6-promise
tsd install es6-promise
tsc
node main.js
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…