TypeScript各种文件扩展名解释?(TypeScript various file extensions explained?)

编程入门 行业动态 更新时间:2024-10-28 13:20:49
TypeScript各种文件扩展名解释?(TypeScript various file extensions explained?)

在试图理解TypeScript中 ,所有文件扩展名之间的关系是什么?

TypeScript, *.ts 定义, *.d.ts 地图, *.map地图 JavaScript, *.js

In 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

“编译”为纯JavaScriptJavaScript类型超集。 这些文件有可能利用IDE智能感知的类型安全强类型语法。

定义, *.d.ts

A *.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.ts

A *.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, *.map

A .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, *.js

According 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.

更多推荐

本文发布于:2023-07-05 08:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1035429.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件扩展名   TypeScript   file   explained   extensions

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!