如何编写 Typescript 插件? [英] How to write a Typescript plugin?

查看:29
本文介绍了如何编写 Typescript 插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

最后一次将 Typescript 引入我的项目的想法给了我很大的启发.但是,目前我认为这是不可能的,因为我失败尝试查找有关编写 Typescript 插件的任何文档.我需要这个插件来在编译期间组合类元数据,然后生成资产.这不是那么容易,但我已经已经写这样的babel 现在我很感兴趣是否可以用 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.

推荐答案

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

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

npm install typescript

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

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.

https://github.com/Microsoft/TypeScript/wiki/使用编译器 API

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

这篇关于如何编写 Typescript 插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆