Sublime Text我爱编程 移动 前端 Python Android Java

搭建Sublime的TypeScript开发环境

2018-03-09  本文已影响117人  Floyda

搭建Sublime的TypeScript开发环境

1. 安装TypeScript

安装Node.js, 然后npm install typescript -g

2. 安装Sublime的TypeScript插件

微软官方出品, 提供语法高亮, 代码补全, 定义跳转, 代码格式化等等功能

3. 修改TypeScript.sublime-build

Packages/User新建TypeScript.sublime-build, 或者在原文件(Packages/TypeScript/TypeScript.sublime-build)中修改.

{
    "selector": "source.ts, source.tsx",
    "shell":true,
    "windows":
        {
            "cmd": ["tsc", "$file", "&&", "node", "$file_base_name.js"]
        },
}

4. 自定义快捷键

{ "keys": ["ctrl+alt+f"], "command": "typescript_format_document", "context":[{"match_all": true, "operator": "equal", "key": "selection_empty", "operand": true}, {"match_all": true, "operator": "equal", "key": "num_selections", "operand": 1}, {"operator": "equal", "key": "selector", "operand": "source.ts, source.tsx"}]},

5. 自定义Snippet

<snippet>
    <content><![CDATA[for (let ${1:i} in ${2:Object}) {
    ${0:// code...}
}]]></content>
    <tabTrigger>forin</tabTrigger>
    <scope>source.ts, source.tsx</scope>
    <description>for … in … loop</description>
</snippet>

上一篇下一篇

猜你喜欢

热点阅读