This project has moved. For the latest updates, please go here.

Confusion about TypeScript references and bundler transformer adapter

Jan 25, 2013 at 12:19 AM
Edited Jan 25, 2013 at 12:21 AM
Using the NuGet package BundleTransformer.TypeScript version 1.6.16 ...
Seems like it should be very easy.
<head>    ...
    <script src="App/app.ts"></script>
But if my app.ts includes references as in the current documentation, the javascript for app.ts is delivered, but the dependency files are not included.
/// <reference path="MoreCode.ts" />
/// <reference path="../d.ts/jquery-1.8.d.ts" />
/// <reference path="../d.ts/knockout-2.2.d.ts" />
/// <reference path="../d.ts/jqueryui-1.9.d.ts" />

window.onload = () => {
    // MoreCode and MoreCode.DoSomething() are defined in MoreCode.ts, of course

The documentation seems to think it's obvious that this should work - that MoreCode.ts should be compiled into the requested output.
Instead I just get the following at the client and an error message in the browser debugger saying that "MoreCode" is not defined.
window.onload = function () {

Can you please clarify the intended behavior and help me diagnose the issue?
If the bunder needs to be given these paths explicitly, then where??
Jan 25, 2013 at 2:04 PM

Hello, Admiristrator!

"Reference" comments are not "include" or "import" directives. "Reference" comments just tell то the compiler what types should be considered when compiling. You must explicitly add all TS-files to Bundle.

For a start i recommend to read tutorial "Bundling and Minification" and see examples of Bundle Transformer usage.

Jan 25, 2013 at 6:27 PM


Hi Taritsyn,

Thank you for this reply.  That explains why I couldn't get it working.  :-)

I recommend that the relevant parts of the documentation be more explicit on these points -- or did I miss a place that makes it obvious that including the references is not enough to compile a single bundled download of all dependencies?

I have two followup questions:

1) If you're not bundling them, why does the bundler specifically require that the references are present?  Can't the transformation of TS-to-JS work perfectly well if the type-checker were to be disabled?  I can't think of any situations where the output transformed code would change based on the content of the other file (except in the case of a complete failure which I figure you could disable). I'm really just trying to figure out why the documentation mentions this as a requirement beyond normal TypeScript authorship.

2) If these refererences ARE explored, wouldn't it be easy to link in all the dependencies and generate the bundled download?  What are the obstacles there?