如何为 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
How to configure a Sublime Build System for TypeScript
提问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"]
}
}

