-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Domain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptNeeds More InfoThe issue still hasn't been fully clarifiedThe issue still hasn't been fully clarified
Description
🔎 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
Metadata
Metadata
Assignees
Labels
Domain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptNeeds More InfoThe issue still hasn't been fully clarifiedThe issue still hasn't been fully clarified