TypeScript: include files or multiple output files

Sep 14, 2014 at 10:02 AM
Edited Sep 14, 2014 at 10:04 AM
I currently try to build two google chrome extensions using nodejs tools and TypeScript (yes, I know that this actually has nothing to do with nodejs, but the project settings are awesome!). Both extensions rely on some shared classes and interfaces. Here begins the pain.

I created two projects. As one knows, chrome extensions require you under some circumstances to have more than one js file (e. g. a background script, a popup page, a 'load-me-at-the-end-of-the-page' script). Therefor, I can't use the 'compile stuff into one file' option although I think I actually need it in some way. The point is: when I create my background.ts file and rely on classes and interfaces defined in the shared scripts, chrome fails to load (of course) since these definitions are not there at the time of loading. But because I have other scripts in the same project (e. g. popup.ts) I can't redirect everything inte one file.

The next problem appears is that it is difficult to have a shared folder. Afaik it is impossible to reference folders in a Visual Studio project which are up to the current location of the project. Because of that, I can't include the shared folder into all projects without creating unmaintainable copies. So I abused the ///<reference> way. Problem: nodejs tools don't recognize them well for IntelliSense and they are not actually included into the target file, which runs me into the same problem explained above.

Am I doing anything wrong? What are the best practices here? Or is it - simple speaking - currently not possible to achieve what I want with the comfort of nodejs tools?
Coordinator
Sep 23, 2014 at 5:05 PM
Edited Sep 23, 2014 at 5:05 PM
Have you tried creating symbolic links to the backing files? If you need the same files in multiple folders this is the easiest way to do it.

Let's say you wanted Shared Folder under A as well as at the root of the project.
A/Shared Project
./Shared Project

You could just run the mklink command from an admin command prompt.
http://technet.microsoft.com/en-us/library/cc753194.aspx

This way you can give the appearance that there are copies of the files in different places while maintaining the one file.
Marked as answer by crwilcox on 9/23/2014 at 10:05 AM
Sep 27, 2014 at 9:24 PM
Hi,

this is what I did now although it is a very bad solution imho.

Thanks!