So far, I have been using typescript internal modules and have included 10s of script tags to load my application. I'm in the process of converting a project to use external modules (using a browser), but I'm stuck with how I should convert the listings.
I had something like:
mymodule.submodule { enum MyEnum { one, two, three } }
and I will use it in other modules, for example:
var val:mymodule.submodule.MyEnum = mymodule.submodule.MyEnum.one;
and this compiled for js correctly. After converting the project to using external modules, I moved all my interfaces to * .d.ts files and thought about putting enums in there, but of course this caused an error because there was no comparison between the enumeration and the number in js, then I moved the enumerations to * .ts files so that they are compiled. The problem is that if I write them as:
export enum MyEnum{ one, two, three } export enum OtherEnum { four, five, six }
which works to request enumerations in my code like:
import Enums = require('./enums'); var val = Enums.MyEnum.one;
BUT is not compatible with type mymodule.submodule.MyEnum . So, how can I have as an declaration for an enumeration type, so that I can declare variable types inside d.ts files, but also have a dependency on the actual generated enumeration code (so that it is loaded correctly) and used in the .ts file?
Note: these enumerations are used in many modules, so including them in the same file that they use is not a solution.
UPDATE about interface declarations: it was probably not clear why I saved the original listing declarations in d.ts files, so I add an example.
in .d.ts interfaces I currently have:
declare module mymodule.submodule { enum MyEnum{ one, two, three } interface ISomething{ aValue: MyEnum; aFunction: (anArg: MyEnum) => void; } }
As far as I know, I cannot use import instructions in .d.ts files, since I can use a single enum declaration in all cases?