I am using Visual Studio 2013 with Update 4 and Typescript 1.3.
If I have a Typescript file, for example:
MyEnums.ts:
export = MyEnumModule; module MyEnumModule { export enum AnEnum { RED, BLUE, GREEN } }
And I have a definition file like:
MyDefinitions.d.ts:
declare module MyDefinitions { interface ISomeInterface { aProperty: string; aMethod: () => void; aColor: MyEnumModule.AnEnum; } }
Basically I get the error message "I can not find the name" MyEnumModule "
This enumeration file works fine when linking from Typescript files. For example:
SomeCode.ts:
export = MyCode; import MyEnums = require('MyEnums'); module MyCode{ export class MyClass implements ISomeInterface { public aColor: MyEnums.AnEnum = MyEnums.AnEnum.RED; ...and so on
I understand that adding either /// <reference ... or import will not work for the .d.ts file (I tried to just be sure, and it didn't seem to work anyway).
Does anyone know how to reference an enumeration in a definition file like this?
Thanks in advance.
- Update:
Here is the error that I see after you tried the recommendations of Steve Fenton below (with the example I just made).
MyDefinitions.ts
import MyEnumModule = require('../App/MyEnums'); declare module MyDefinitions { interface ISomeInterface { aProperty: string; aMethod: () => void; aColor: MyEnumModule.AnEnum; } }
MyEnums.ts
export = MyEnumModule; module MyEnumModule { export enum AnEnum { RED, BLUE, GREEN } }
Myclass.ts
export = MyCode; import MyImport = require('MyEnums'); module MyCode { export class MyClass implements MyDefinitions.ISomeInterface { public aColor: MyImport.AnEnum = MyImport.AnEnum.RED; constructor() { } aProperty: string = ""; aMethod: () => void = null; }
}
Folder structure :
The app
-MyClass.ts -MyEnums.ts
DEFINITIONS -MyDefintions.d.ts
Inside MyClass.ts, MyDefinitions.ISomeInterface is highlighted in red with a warning about the hang "Cannot find the name MyDefinitions."
I have AMD installed for the project