0

I have the following directory setup:

/app/ioc.ts
/tests/test.ts

I'm in the tests directory. The contents of app/ioc.ts are unimportant, but the contents of tests/test.ts are:

import IOC = module('../app/ioc');
var container = new IOC.Container();

If I compile this like so:

tsc test.ts

Then run it like so:

node test

All's good! The file runs without errors. However! If I run it like this:

tsc -e test.ts

I get the following error:

module.js:340
    throw err;
          ^
Error: Cannot find module '../app/ioc'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (D:/dropbox/work/sandbox/Prototyping/TypeScript/tests/test.js:1:73)
    at Module._compile (module.js:456:26)
    at Object.run (C:\Users\nathan\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:56041:30)
    at BatchCompiler.run (C:\Users\nathan\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:56563:29)
    at BatchCompiler.batchCompile (C:\Users\nathan\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:56795:26)
    at Object.<anonymous> (C:\Users\nathan\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:56908:7)

Any ideas?

1 Answer 1

1

Your code is fine. The -e flag is being removed from tsc, partly because it doesn't play nicely with this sort of scenario. Executing arbitrary JS in the context of the compiler process turns out to not be a good idea.

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.