在试图理解TypeScript中 ,所有文件扩展名之间的关系是什么?
TypeScript, *.ts 定义, *.d.ts 地图, *.map地图 JavaScript, *.jsIn trying to understand TypeScript a little more, what are the relations between all of the file extensions?
TypeScript, *.ts Definition, *.d.ts Map, *.map JavaScript, *.js最满意答案
我最初开始进入上面的问题,想着自己会有人来帮助我。 然后我注意到了“回答你自己的问题”选项,我受到了Jeff Atwood令人鼓舞的博客文章的启发 - 所以我决定我应该尝试回答我自己的问题。 我不得不做一些研究,但现在我有我最初寻找的理解。
TypeScript, *.ts
“编译”为纯JavaScript的JavaScript类型超集。 这些文件有可能利用IDE智能感知的类型安全和强类型语法。
定义, *.d.tsA *.d.ts文件用于提供有关用JavaScript编写的API的 TypeScript类型信息。 类型定义文件包含相应.js所有公共API的定义类型,例如 - JQuery具有不带jQuery.d.ts一个使用jQuery的TypeScript文件不知道其类型,因此intellisense是不见了。
地图, *.map.map文件是一个源映射文件,它允许工具在发出的JavaScript代码和创建它的TypeScript源文件之间“映射”。 这个概念自CoffeeScript以来一直存在。
JavaScript, *.js根据MDN :
JavaScript是一种跨平台,面向对象的脚本语言。 它是一种小巧轻便的语言。 在主机环境(例如,Web浏览器)内部,JavaScript可以连接到其环境的对象以对其进行编程控制。
.ts文件和.js文件之间的关系是TypeScript文件编译为JavaScript文件。
I initially started entering the question above thinking to myself that someone would come along and help me out. Then I noticed an "answer your own question" option and I was inspired by Jeff Atwood's encouraging blog post - so I decided I should attempt to answer my own question. I had to do some research but now I have the understanding I was originally looking for.
TypeScript, *.ts
A typed superset of JavaScript that "compiles" to plain JavaScript. These files have the potential to utilize type-safety and strongly-typed syntax, with IDE intellisense.
Definition, *.d.tsA *.d.ts file is used to provide TypeScript type information about an API that's written in JavaScript. Type definition files contain the defining types for all of the public APIs within a corresponding .js, for example - JQuery has jQuery.js without the jQuery.d.ts a TypeScript file consuming jQuery wouldn't know about its types, therefore intellisense is gone.
Map, *.mapA .map file is a source map file that let tools "map" between the emitted JavaScript code and the TypeScript source files that created it. This concept has been around since CoffeeScript.
JavaScript, *.jsAccording to MDN:
JavaScript is a cross-platform, object-oriented scripting language. It is a small and lightweight language. Inside a host environment (for example, a web browser), JavaScript can be connected to the objects of its environment to provide programmatic control over them.
The relationship between a .ts file and a .js file is that a TypeScript file compiles down to a JavaScript file.
更多推荐
发布评论