2

I compile the following code using the latest typescript compiler (1.4)

/// <reference path="typescript.d.ts" />

//import ts = require("typescript");
module cc {
console.log("Hello");
}

using the following compile args

node /TypeScript/built/local/tsc.js -m commonjs --noEmitOnError app.ts -out myApp.js

which compiles Ok and generates the "myApp.js" file.

When I uncomment the import line, I get no error on compiling, but it generates an empty (zero size) "myApp.js" and a file "app.js", even I have specified the --noEmitOnError switch.

This is a strip down example, in fact I specify multiple ".ts" files and I get no error on compiling, the empty "myApp.js" file and for each ".ts" file I specified, I get a ".js" file.

I am using node 0.10.30 on Windows 8.1

2
  • It's a local copy of /TypeScript/built/local/typescript.d.ts Commented Dec 18, 2014 at 14:44
  • I see this behavior as well. What happens if you rename the typescript.d.ts file to somethingelse.d.ts and try to import that instead? If it "works" by saying that it's not an external module, then you may have uncovered a bug that should be reported on GitHub. Commented Dec 18, 2014 at 15:33

1 Answer 1

5

The --out flag generally should not be used with external modules. Only code that is not part of an external module will be written to the specified output file. Files with a top-level import are an external module.

See also modules documentation, this GitHub issue tracking

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.