Folks, I'm trying to do something that I thought ought to be simple, but I must be doing something wrong. I'm trying to simply have a clear structure in my meteor application which uses Typescript.
Here are my requirements:
- All interfaces are available in both client and server
- Some class implementations are only available on the server
- I don't want to rely on file load order for my application to work properly
- I need my own module to not clash with global objects (such as the Position class for example)
- I need to have one monolithic include file for server, one for both client and server and one for client (don't want to have 10s of includes on top of my files)
The setup that I have right now is this
- server
- server-book.ts
- client
- shared
- collections.ts
- definitions
- server
- include.d.ts (includes all .d.ts files in this folder)
- server-book.d.ts (server specific implementation of book)
- client
- shared
- include.d.ts (includes all .d.ts files here)
- book.d.ts (book interface definition)
- collections.d.ts
- server
In each .d.ts file I have
module MyModule { interface Bla {} };
In each .ts file that defines a class I have:
module MyModule { export class MyBla implements Bla {}; }
All .d.ts files generated for classes are generated by tsc -d.
No .ts files are being included via ///<reference> rather only .d.ts files.
Now, when I run this, I get an error that MyModule is undefined:
/// <reference path="shared/include.d.ts"/> /// <reference path="server/include.d.ts"/> Meteor.startup(() => { var temp = new MyModule.ServerBook(); });
The error occurs right on MyModule.
What am I doing wrong? What should be the proper setup here?
Thanks!