microsoft / microsoft/TypeScript

Unexpected "used before its declaration" error when implementing a exported type of a merged namespace

Aperta
#54,429 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Domain: Binder Help Wanted Needs Human Review Needs More Info
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

Bug Report

🔎 Search Terms

used before its declaration vscode

🕗 Version & Regression Information
  • tested in 4.7.3, 5.0.4 and nightly
⏯ Playground Link

Playground link with relevant code

💻 Code
namespace Foo {
    export interface Bar { }
}

class X implements Foo.Bar {

}

const Foo = 1;
🙁 Actual behavior

In VSCode it reports:

namespace Foo
Block-scoped variable 'Foo' used before its declaration.ts(2448)
Untitled-1(9, 7): 'Foo' is declared here.
Variable 'Foo' is used before being assigned.ts(2454)

You may not see the error immediately if you paste the code into a new file. It will appear when you start typing something.

Note that the error cannot be reproduced in the playground.

🙂 Expected behavior

No error.

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 con l’esempio TypeScript fornito e il link al Playground, quindi confronta la diagnostica dell’editor con il comportamento del Playground per il namespace unito e il tipo esportato. Segui il percorso del controllo dei tipi che segnala gli errori "used before its declaration" e "used before being assigned", quindi aggiungi un test di regressione che mostri che questo codice non produce errori.

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

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.