KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In our project we're using RequireJS as our module loader. Some of our modules will influence global libraries, and hence won't be directly used within the module they are referenced in. Example: define(['definitely/goingto/usethis/','just/referencingthis/forpackaging'], function(useThis) { useThis.likeIPromised(); // the following call can only be made when the second required file is available someGlobalAvailableVariable.someMethod(); }); This works as expected when writing my modules in JavaScript. However, we're translating our project step by step to TypeScript. Given the example above, this results in: import useThis = module("definitely/goingto/usethis/"); import whatever = module("just/referencingthis/forpackaging"); useThis.likeIPromised(); // I've written a definition file so the following statement will evaluate someGlobalAvailableVariable.someMethod(); And when compiling this to JavaScript, the compiler wants to be helpful and removes any unused imports . As such, this breaks my code, cause the second imported module isn't available. My current work around is to include a redundant assignment, but this looks ugly: import whatever = module("just/referencingthis/forpackaging"); var a = whatever; // a is never ever used further down this module Does anyone know if it's possible to configure the TypeScript compiler to not optimize modules during compile?
Tags (comma-separated)
Save Edits
Cancel