【问题标题】:How to write a Typescript plugin?如何编写 Typescript 插件?
【发布时间】:2016-11-09 17:53:22
【问题描述】:

是否有编写 Typescript 插件的文档/示例?


最后一次,我对将 Typescript 引入我的项目的想法非常有启发。但是,目前我认为这是不可能的,因为我失败尝试找到任何有关编写 Typescript 插件的文档。我需要这个插件在编译期间组合类元数据,然后生成资产。这不是那么容易,但我有 already written 这样的 babel 现在我很感兴趣是否可以对 Typescript 做同样的事情。

【问题讨论】:

标签: javascript typescript plugins abstract-syntax-tree transpiler


【解决方案1】:

你可以下载https://github.com/microsoft/typescript或通过npm。

npm install typescript

然后将其包含到您的项目中,并通过 Compiler APITypeScript Language Service 使用 TypeScripts 代码。如果需要,您可以编写自己的编译器。 wiki 上描述了基础知识。

https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API

https://github.com/Microsoft/TypeScript/wiki/Using-the-Language-Service-API

【讨论】:

    【解决方案2】:

    现在有一些可用于语言服务插件的文档:

    https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin

    但请注意language service is not called by the tsc command,但仅来自应用程序(我相信通常是 IDE / 编辑器)。

    https://github.com/cevek/ttypescript 项目修补了tsc 以支持转换器,这可能也是需要tsc 命令支持的人的途径。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-07
      • 1970-01-01
      • 2019-04-06
      • 2015-04-27
      • 2010-11-20
      • 2010-09-06
      • 2011-05-10
      • 1970-01-01
      相关资源
      最近更新 更多