microsoft / microsoft/TypeScript
[JS] accessing nested namespaces from require() with destructuring leads to an error
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
TypeScript Version: 4.2.0-dev.20201126
Search Terms: TS2305
Code
// Must be in JS mode, works in TS mode
const { HttpUriPlugin } = require("webpack").experiments.schemes;
// TS2305: Module '"webpack"' has no exported member 'schemes'.
// Syntax equivalents that work:
const schemes = require("webpack").experiments.schemes;
const HttpUriPluginAlternative1 = require("webpack").experiments.schemes.HttpUriPlugin;
const { schemes: { HttpUriPlugin: HttpUriPluginAlternative2 } } = require("webpack").experiments;
console.log(HttpUriPlugin);
console.log(schemes.HttpUriPlugin);
console.log(HttpUriPluginAlternative1);
console.log(HttpUriPluginAlternative2);
Expected behavior:
Destructuring a nested namespace in JS mode doesn't lead to an error
Actual behavior:
An error is emitted.
The error also looks a bit weird:
Module '"webpack"' has no exported member 'schemes'.
Something like Namespace 'experiments' has no exported member 'schemes'. would make more sense.
It seems like it looks up schemes on the wrong type...
Playground Link: Link
Related Issues:
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 la riproduzione collegata in Playground in modalità JavaScript e confronta la forma di destrutturazione annidata con le forme equivalenti funzionanti mostrate nell’issue. Segui la diagnostica per require("webpack").experiments.schemes e verifica che il namespace annidato venga controllato correttamente e che non venga emesso alcun TS2305 errato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, 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
- 35/100