Get TypeScript class in a file and read single parts of it

前端 未结 1 1151
孤街浪徒
孤街浪徒 2021-01-29 02:00

Is there a plugin (like for Gulp) where I can parse a typescript file and read out single parts (like a member, a function, comments), etc.

So that I have a class like t

1条回答
  •  借酒劲吻你
    2021-01-29 02:32

    Jed mao has an excellent (but under appreciated) project that open's up the TypeScipt compiler api for commonjs consumption : https://www.npmjs.org/package/typescript-api

    It ships with a definition file : https://github.com/jedmao/typescript-api/blob/master/typescript-api.d.ts

    The logic inside it is blatantly simple : https://github.com/jedmao/typescript-api/blob/master/wrapper.js#L15-L28 it bascially just opens up tsc.js with a module.exports = TypeScript;

    Usage

    You will basically need to investigate how TypeScript does its work. But PullTypeSymbol which has public getMembers(): PullSymbol[]; seems to be in the worth searching in the TypeScript Source code (https://typescript.codeplex.com/)

    0 讨论(0)
提交回复
热议问题