Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Cannot compile codes to ES5 that using Promise (that tsc can do it) #96

Open
Narazaka opened this issue Jan 6, 2018 · 0 comments
Open

Comments

@Narazaka
Copy link

Narazaka commented Jan 6, 2018

TypeScriptSimple cannot compile codes to ES5 that using Promise (that tsc can do it).

So also espower-typescript cannot compile codes to ES5 and test fails.

minimal example:

package.json

{
  "dependencies": {
    "typescript": "^2.6.2",
    "typescript-simple": "^8.0.5"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "es5",
      "es2015.promise"
    ]
  }
}

a.ts

const a = async () => 1;

tss.js

const TypeScriptSimple = require('typescript-simple').TypeScriptSimple;
const fs = require("fs");

const compilerOptions = require("./tsconfig.json");
const tss = new TypeScriptSimple(compilerOptions, false);
tss.compile(fs.readFileSync("./a.ts", "utf-8"), "./a.ts");
$ tsc # no error
$ node tss.js
Error: Cannot find global value 'Promise'.
    at TypeScriptSimple.toJavaScript (O:\a\node_modules\typescript-simple\index.js:162:23)
    at TypeScriptSimple.compile (O:\a\node_modules\typescript-simple\index.js:73:25)
    at Object.<anonymous> (O:\a\tss.js:6:5)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant