microsoft / microsoft/TypeScript

An error occurs when passing the SourceFile node to getTypeAtLocation.

Aperta
#62,190 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Domain: API Needs More Info
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

🔎 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.
Image

When executing the isDeclarationNameOrImportPropertyName method, the passed node is still the SourceFile node, and an error is directly reported at name.parent.
Image
Image

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo l’esempio ModuleA/ModuleB fornito e segui getTypeAtLocation attraverso getTypeOfNode, isExternalModule e isDeclarationNameOrImportPropertyName. Verifica che il passaggio del nodo SourceFile non causi più l’errore name.parent e che getTypeAtLocation restituisca un tipo o errorType come previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.