microsoft / microsoft/TypeScript
Named import for 'any'-typed module doesn't work
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Bug Report
🔎 Search Terms
any module export assignment named import
🕗 Version & Regression Information
TypeScript v4.1.2
💻 Code
mock.d.ts
declare const _: any;
export = _;
example.ts
import { a } from "./mock";
import * as b from "./mock";
const { c } = b;
const { d } = await import("./mock");
console.log(a, c, d);
tsconfig.json
{
"compilerOptions": {
"module": "ESNext",
"strict": true,
"target": "ESNext",
},
"include": [
"./**/*.ts"
]
}
🙁 Actual behavior
The first import returns the diagnostic:
error TS2305: Module '"./mock"' has no exported member 'a'.
While c and d do not error.
🙂 Expected behavior
With an export being effectively any, I would expect default, namespace, dynamic and named imports to all behave as if the module was any. I cannot find any other way to declare a module in a fashion where the compiler treats any import from that module as any and does not issue diagnostics.
As implied in the above, there are certain situations where there is a need to "mock" a module where its shape cannot be statically determined at compile time.
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
Riproduci il report usando mock.d.ts, example.ts e tsconfig.json, quindi traccia il modo in cui il compilatore TypeScript gestisce gli import denominati da un modulo di assegnazione dell’export tipizzato come any. Il lavoro è completo quando l’import denominato non segnala più TS2305, mantenendo al contempo il comportamento mostrato per gli import di namespace e dinamici.
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
- 35/100