Typescript --allowJs 如何工作? [英] How does Typescript --allowJs work?

查看:54
本文介绍了Typescript --allowJs 如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读:

但我仍然不明白它是如何工作的以及它有什么好处.可以有人请解释它是什么以及我什么时候想使用它?

but I still don't get how it works and what it is good for. Could someone please explain what it is and when I would want to use it?

推荐答案

来自 Clay Allsopp on Medium:

allowJs 是 1.8 中新提供的选项.打字稿编译器将对 .js 文件运行快速健全性检查以查找语法错误,但否则将它们直接传递到输出目录.

allowJs is the option newly available in 1.8. The TypeScript compiler will run a quick sanity check on .js files for syntax errors but otherwise passes them straight through to the output directory.

这在将 JavaScript 项目迁移到 TypeScript 时很有用,这样您就不必一次迁移所有内容,而是开始在 TypeScript 中编写新代码和/或逐个迁移每个文件.您可以在 TypeScript 的官方网站上找到有关从 JavaScript 迁移到 Typescript 的更多信息,该网站有一个名为从 JavaScript 迁移".

This is useful when migrating a JavaScript project to TypeScript, that way you don't have to migrate everything at once but instead start writing new code in TypeScript and/or migrate each file one by one. You can find more information about migration from JavaScript to Typescript on the official site for TypeScript that has a tutorial called "Migrating from JavaScript".

这篇关于Typescript --allowJs 如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆