【发布时间】:2019-11-16 06:23:43
【问题描述】:
按名称获取导出符号的最佳方法是什么?
下面是功能代码。但是,它似乎有点脆弱,因为我无法在不忽略类型系统的情况下从“sourceFile”获取“符号”。
const sourceFile = tsprogram.getSourceFile('foo_file.ts');
const fileSymbol = (sourceFile as any).symbol as ts.Symbol; // anything better her?
const export = fileSymbol.exports.get('FooComponent');
【问题讨论】: