【发布时间】:2020-06-21 22:22:57
【问题描述】:
如何使用 TypeScript Compiler API 来提取数组的类型?例如给定这个来源:
let a: string[] = []
我怎样才能从string[] 类型变成string?
ts-morph 让这一切变得简单,但我还没有弄清楚如何使用原始 TS Compiler API 复制它。
看来我需要使用checker.getTypeArguments(),但它需要一个我不知道如何创建的ts.TypeReference 类型。
【问题讨论】:
-
这能回答你的问题吗? Test for array of string type in TypeScript
-
我在元级别询问,TypeScript Compiler API。标题相应更新。
标签: typescript typescript-compiler-api