【问题标题】:TypeScript Compiler API to access base interfaces or classes用于访问基础接口或类的 TypeScript Compiler API
【发布时间】:2020-07-31 08:34:56
【问题描述】:

我在小插件上使用TypeScript Compiler API, 我很好奇如何从NodeObject 获取它扩展的所有接口或类?

我在TypeScript Compiler API 文档中没有找到有用的示例...

任何帮助将不胜感激...

【问题讨论】:

    标签: typescript typescript-compiler-api


    【解决方案1】:

    我已经找到答案了,

    可以使用heritageClauses:

    if (node.heritageClauses) {
       for(const hc of node.heritageClauses) {
          console.log("heritage clause: " + hc.getText()); // prints "extends ..."
       }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-02-03
      • 2019-05-04
      • 2016-12-30
      • 1970-01-01
      • 1970-01-01
      • 2014-09-10
      • 2010-10-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多