如何编写Typescript插件?

时间:2023-01-14 14:55:48

Are there any docs / examples of writing a Typescript plugin?

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


For the last time I am very inspired with the idea of bringing Typescript into my projects. However, currently I see this is not possible because of my failed attempts to find any docs about writing a Typescript plugin. I need this plugin for combining classes metadata during compilation and then generating an asset. It was not that easy but I've already written such for babel and now I am interested if it is possible to do the same with Typescript.

最后一次,我非常鼓励将Typescript引入我的项目。但是,目前我发现这是不可能的,因为我没有尝试找到有关编写Typescript插件的任何文档。我需要这个插件在编译期间组合类元数据然后生成资产。这不是那么容易,但我已经为babel编写了这样的内容,现在我感兴趣的是如果可以对Typescript做同样的事情。

1 个解决方案

#1


2  

You can download https://github.com/microsoft/typescript or via npm.

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

npm install typescript

Then include it into your project and via Compiler API or TypeScript Language Service work with TypeScripts codes. You can write your own compiler if you need. Basics are described on the wiki.

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

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

#1


2  

You can download https://github.com/microsoft/typescript or via npm.

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

npm install typescript

Then include it into your project and via Compiler API or TypeScript Language Service work with TypeScripts codes. You can write your own compiler if you need. Basics are described on the wiki.

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

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