typescript 加载typescript模块依赖的三种方式有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29524061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between the three ways of loading typescript module dependencies?
提问by Nefarious
What is the difference between the following ways of loading typescript module dependencies?
以下加载 typescript 模块依赖项的方式有什么区别?
/// <amd-dependency path="someFile"/>
/// <reference path="someFile.ts" />
import someFile = require("someFile");
采纳答案by basarat
Covered here : https://typescript.codeplex.com/wikipage?title=Modules%20in%20TypeScript
此处涵盖:https: //typescript.codeplex.com/wikipage?title =Modules%20in% 20TypeScript
Disclaimer : My strong opinions follow: https://www.youtube.com/watch?v=KDrWLMUY0R0&hd=1
免责声明:我的强烈意见如下:https: //www.youtube.com/watch?v=KDrWLMUY0R0&hd=1
import someFile = require("someFile");
import someFile = require("someFile");
This should be your main form of import. Use this for JS libraries import $ = require("jquery");
as well as its relative file variant for your own files
import someFile = require("./someFile");
这应该是您的主要进口形式。将此用于 JS 库import $ = require("jquery");
及其相对文件变体用于您自己的文件
import someFile = require("./someFile");
/// reference path="someFile.ts" /
/// 参考路径="someFile.ts" /
use this only to import typeinformation from .d.ts
files and your very own globals.d.ts
or vendors.d.ts
or tsd.d.ts
使用此只导入型的信息,.d.ts
文件和你自己globals.d.ts
或vendors.d.ts
或tsd.d.ts
amd-dependency path="someFile"
amd-dependency path="someFile"
You don't need this unlessyou want to require
stuff in CSS/ imagesintoyour TS.
除非您想将CSS/图像require
填充到TS 中,否则您不需要它。