简体   繁体   中英

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" />

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM