如何从另一个(开发时)程序访问TypeScript中的类型信息? [英] How do I get an access to type information in TypeScript from another (development-time) program?

查看:53
本文介绍了如何从另一个(开发时)程序访问TypeScript中的类型信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在TypeScript中获得函数参数类型的列表.从Google搜寻结果一目了然,TypeScript缺乏Java类的反映.我以为可能有某种编译器API可以获取此类数据以满足IDE开发需求等.但是我没有找到.

I would like to get a list of function's arguments' types in TypeScript. As it got obvious from a glance on Google search results, TypeScript lacks Java-kind reflection. I've thought there could be some kind of compiler API to get such data for IDE development needs etc., but I've found none.

那么我如何从另一个程序(构建工具,lint等)访问TypeScript中的类型信息?

So how do I get an access to type information in TypeScript from another program (build tool, lint etc.)?

推荐答案

我认为可能会有某种编译器API来获取此类数据以满足IDE开发需求等,但是我没有找到.

I've thought there could be some kind of compiler API to get such data for IDE development needs etc., but I've found none.

它称为"TypeScript语言服务".有适用于此的文档: https://github.com/Microsoft/TypeScript/wiki/使用语言服务API

Its called the "TypeScript Language Service". There are docs for it : https://github.com/Microsoft/TypeScript/wiki/Using-the-Language-Service-API

我还有一个使用它的OSS项目: https://atom.io/packages/atom-具有AST查看器和快速修复体系结构之类的打字稿:

Also I have an OSS project that uses it : https://atom.io/packages/atom-typescript that has stuff like an AST viewer and a quickfix architecture : https://github.com/TypeStrong/atom-typescript/blob/master/CONTRIBUTING.md#quickfix

还有一本书,其中包含一些编译器文档 http://basarat.gitbooks.io/typescript/content/docs/compiler/overview.html

Also have a book with some compiler docs http://basarat.gitbooks.io/typescript/content/docs/compiler/overview.html

这篇关于如何从另一个(开发时)程序访问TypeScript中的类型信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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