0
interface ImportDeclaration extends Statement {
kind: SyntaxKind.ImportDeclaration;
importClause?: ImportClause;
moduleSpecifier: Expression;
}
我无法找到一个用例是moduleSpecifier
不是StringLiteral
'ImportDeclaration.moduleSpecifier`应该总是StringLiterial吗?
谢谢Daniel。然而,这个评论描述了什么,但没有描述它为什么这样做。看看代码,看起来好像是因为'import'和'export'都使用了这个函数。也许改进它的一种方法是使其返回正确类型的通用函数? 为什么我要问是因为'ImportDeclaration.moduleSpecifier'不是'StringLiteral'令人困惑,让人想知道还有什么可以做的,并且需要执行额外的转换才能获得'.text'。 – unional
我的编辑更清楚了吗? –
我明白了。你的意思是说,如果'importSpecifier'是'StringLiteral',那么整个导入语句将无法解析,并且整个语句会出错?目前,我们可以将错误隔离到'importSpecifier'表达式,并在屏幕截图中报告错误。 – unional