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