microsoft / microsoft/TypeScript
An error occurs when passing the SourceFile node to getTypeAtLocation.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
🔎 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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das bereitgestellte ModuleA/ModuleB-Beispiel zu reproduzieren, und verfolge getTypeAtLocation durch getTypeOfNode, isExternalModule und isDeclarationNameOrImportPropertyName. Überprüfe, dass die Übergabe des SourceFile-Knotens nicht mehr den Fehler name.parent verursacht und dass getTypeAtLocation wie erwartet einen Typ oder errorType zurückgibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100