microsoft / microsoft/TypeScript
`export let` variable doesn't require the variable to be assigned within current file
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
### 🔎 Search Terms
`export let`, `undefined`, assignment, assigned
### 🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about `export let`
### ⏯ Playground Link
_No response_
### 💻 Code
```ts
// a.ts
export let x: { foo(): void }
if (!!false) {
// @ts-expect-error Variable 'x' is used before being assigned.
x.foo()
}
// b.ts
import { x } from './a.ts'
// TS compiles, throws at runtime
x.foo()
```
### 🙁 Actual behavior
TS compiles, only throws at runtime.
### 🙂 Expected behavior
TS refuses to compile without `!` non-null assertion, with error probably being reported in the exporting module `a.ts` rather than the importing module `b.ts`.
### Additional information about the issue
_No response_
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con l’esempio tra file in a.ts e b.ts e riproduci il comportamento attuale di compilazione e runtime. Traccia il controllo dell’assegnazione definitiva per l’x esportato e il suo utilizzo dopo l’importazione; il lavoro è completato quando il compilatore segnala l’assegnazione mancante invece di consentire il fallimento a runtime.
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à
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100