This project is read-only.

converting existing node.js projects to typescript

Topics: General
Jan 29, 2013 at 12:02 PM
Edited Jan 29, 2013 at 12:03 PM



I ran into this problem when trying to convert an existing node project to typescript.

Is there any work-around for this issue (obviously I could turn the node modules into typescript modules and change `module.exports` to `export function(...)` etc. but that would render the whole "every js file is a valid typescript file" argument meaningless).

Thanks in advance.

Jan 29, 2013 at 4:51 PM

So you are trying to compile two files as separate things? Then call tsc twice, once for each file. Otherwise, compiling them together, the same var at the global scope causes name ambiguity. If you need the var defined globally, it can only be defined once...if you need to reference it from another file, create a ///<reference to the other one. Otherwise, use modules or some other mechanism to avoid polluting the global scope.

Jan 29, 2013 at 5:05 PM

@cretz  Thanks for your response, I will use your ```///<reference``` idea in the future! for now  I ended up turning my node modules into typescript modules.