microsoft / microsoft/TypeScript
An error occurs when passing the SourceFile node to getTypeAtLocation.
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
🔎 Search Terms
getTypeAtLocation && SourceFile
🕗 Version & Regression Information
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ Playground Link
No response
💻 Code
//ModuleA
export let namedOther = null;
//ModuleB
import * as testNs from './ModuleA';
export { testNs };
🙁 Actual behavior
In the statement 'export { testNs }', call getTypeAtLocation on 'testNs' to retrieve its type.
🙂 Expected behavior
It is expected to obtain the returned type, whether the result is errorType or another type, but in reality, an error 'Cannot read properties of undefined (reading 'kind')' will be reported in getTypeAtLocation#getTypeOfNode#isDeclarationNameOrImportPropertyName.
Additional information about the issue
The getTypeOfNode function supports passing a SourceFile node, but if the condition isExternalModule is not met, the SourceFile node will proceed to execute further.
When executing the isDeclarationNameOrImportPropertyName method, the passed node is still the SourceFile node, and an error is directly reported at name.parent.
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された ModuleA/ModuleB の例を再現し、getTypeOfNode、isExternalModule、isDeclarationNameOrImportPropertyName を通じて getTypeAtLocation を追跡します。SourceFile ノードを渡しても name.parent エラーが発生しなくなっていること、および getTypeAtLocation が期待どおりに型または errorType を返すことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100