John Papa
John Papa

Reputation: 22338

TypeScript - Import an External Module without AMD nor CommonJS

Has anyone found a way to import a module from another file without using AMD or CommonJS (using the import keyword)? I don't think this is possible, but I want to double check in case there is some clever way to do it.

Assuming we don't want AMD nor CommmonJS I am just using the ///references syntax to pull the types into the file. That gives me the types and I don't have to use import at all. Just means I have to order the script tags properly myself in the HTML. But I'm OK with that for now.

/// <reference path="router.ts" />

Upvotes: 4

Views: 679

Answers (1)

Fenton
Fenton

Reputation: 251222

Yes - you use the reference comment when you are not using CommonJS or AMD.

How you then bundle your JavaScript files is totally up to you - if you are using ASP.NET the new script bundles are a great solution.

Upvotes: 5

Related Questions