如何为 TypeScript 配置 Sublime 构建系统

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12779631/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:13:31  来源:igfitidea点击:

How to configure a Sublime Build System for TypeScript

sublimetext2typescript

提问by Sambo

I'm looking to configure a Build System in Sublime Text for TypeScript.

我正在寻找在 Sublime Text 中为 TypeScript 配置构建系统。

I'm currently using...

我目前正在使用...

{
  "cmd": ["tsc", "$file"],
  "selector": "source.ts"
}

I'd also like to set the 'file_regex' property to handle error messages.

我还想设置“file_regex”属性来处理错误消息。

Anyone know what to set this to?

有谁知道要设置什么?

回答by Endre Simo

Use this on OS-X:

在 OS-X 上使用它:

{
    "cmd": ["tsc","$file"],
    "file_regex": "(.*\.ts?)\s\(([0-9]+)\,([0-9]+)\)\:\s(...*?)$",
    "selector": "source.ts",
    "osx": {
       "path": "/usr/local/bin:/opt/local/bin"
    }
}

EDIT:

编辑:

Here is the Sublime Build System created for Windows. Tested and working as expected. However you need to include tsc.cmd path in the windows environment, otherwise you should define the root to the Typescript command in the cmdsection below:

这是为 Windows 创建的 Sublime Build System。经测试并按预期工作。但是你需要在 windows 环境中包含 tsc.cmd 路径,否则你应该在cmd下面的部分中定义 Typescript 命令的根:

{
    "cmd": ["tsc","$file"],
    "file_regex": "(.*\.ts?)\s\(([0-9]+)\,([0-9]+)\)\:\s(...*?)$",
    "selector": "source.ts",

    "windows": {
        "cmd": ["tsc.cmd", "$file"]
    }
}

回答by Eugene Ramirez

There are two versions now. This one, or this one. Creating your own is easy, by referring to this document.

现在有两个版本。这一个或这一个。通过参考本文档,创建您自己的很容易。