如何观察和编译所有TypeScript源? [英] How to watch and compile all TypeScript sources?

查看:135
本文介绍了如何观察和编译所有TypeScript源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将宠物项目转换为TypeScript,似乎不能使用 tsc 实用程序来观看和编译我的文件。帮助说,我应该使用 -w 开关,但看起来它不能观看和编译所有 *。ts 文件在一些目录中递归。这看起来像 tsc 应该能够处理。

I'm trying to convert a pet project to TypeScript and don't seem to be able to use the tsc utility to watch and compile my files. The help says I should use the -w switch, but it looks like it can't watch and compile all *.ts files in the some directory recursively. This seems like something tsc should be able to handle. What are my options?

推荐答案

从技术上讲,这里有几个选项:

Technically speaking you have a few options here:

如果您使用类似Sublime Text的IDE和集成的MSN插件Typescript: http://blogs.msdn.com/b/interoperability/archive/2012/10/01/sublime-text-vi-emacs-typescript-enabled.aspx 你可以创建一个自动将 .ts 源编译为 .js 的构建系统。以下是您可以如何做到的解释:如何为TypeScript配置Sublime构建系统

If you are using an IDE like Sublime Text and integrated MSN plugin for Typescript: http://blogs.msdn.com/b/interoperability/archive/2012/10/01/sublime-text-vi-emacs-typescript-enabled.aspx you can create a build system which compile the .ts source to .js automatically. Here is the explanation how you can do it: How to configure a Sublime Build System for TypeScript.

您可以定义甚至将源代码编译为目标 .js 文件保存文件。有一个在github上托管的崇高包: https://github.com/alexnj/SublimeOnSaveBuild 这使得这发生,只有你需要在 SublimeOnSaveBuild.sublime-settings 文件中包含 ts 扩展。

You can define even to compile the source code to destination .js file on file save. There is a sublime package hosted on github: https://github.com/alexnj/SublimeOnSaveBuild which make this happen, only you need to include the ts extension in the SublimeOnSaveBuild.sublime-settings file.

另一种可能性是在命令行中编译每个文件。您可以通过用空格分隔它们来一次编译多个文件,例如: tsc foo.ts bar.ts 。检查此主题:如何传递多个来源文件到TypeScript编译器?,但我认为第一个选项更方便。

Another possibility would be to compile each file in the command line. You can compile even multiple files at once by separating them with spaces like so: tsc foo.ts bar.ts. Check this thread: How can I pass multiple source files to the TypeScript compiler?, but i think the first option is more handy.

这篇关于如何观察和编译所有TypeScript源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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