简体   繁体   English

如何通过查看源代码来区分 typescript 和 javascript?

[英]How can I distinguish typescript from javascript by looking at the source code?

I am inspecting some code on Github and I need to quickly understand if the script is javascript or typescript.我正在检查 Github 上的一些代码,我需要快速了解脚本是 javascript 还是 typescript。

Are there any easy shortcuts or clues to this?是否有任何简单的快捷方式或线索?

As an example, in this image from https://www.typescriptlang.org/ gives me a clue that if an array is declared with a bracket [] after the variable name, then it is typescript.例如,在来自https://www.typescriptlang.org/ 的这张图片中,我提供了一个线索,如果数组在变量名后使用方括号 [] 声明,那么它就是 typescript。

在此处输入图片说明

You can distinguish between the two formats by looking simply at the functions.您可以通过简单地查看函数来区分这两种格式。

Are any of the functions specifying types such as 'string,integer,object,array,function?...' etc?是否有任何指定类型的函数,例如“字符串、整数、对象、数组、函数?...”等?

In traditionally javascript this is not allowed.在传统的 javascript 中这是不允许的。

Best, AT最好的,在

Also as others may have pointed out, you can also check the file extension另外正如其他人可能指出的那样,您还可以检查文件扩展名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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