Multi-line top-level `await` causes duplicate declaration error
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
- Ambito
- compilers
Direzione di ricerca
Inizia con la riproduzione collegata in TypeScript Playground e analizza l’analisi del compilatore di top-level-await e dei moduli in relazione alla diagnostica duplicata di BitSet segnalata. Il lavoro è concluso quando l’esempio non produce né l’errore di identificatore duplicato né l’errore di incompatibilità dei membri privati, con o senza la dichiarazione di modulo vuota.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🔎 Search Terms
typescript top-level await export class "duplicate identifier"
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about await, identifiers, modules
⏯ Playground Link
💻 Code
`
(module
(func (export "i64.popcnt") (param i64) (result i32)
local.get 0
i64.popcnt
i32.wrap_i64))
`
// via https://webassembly.github.io/wabt/demo/wat2wasm/
const wasm = (await
WebAssembly.instantiateStreaming(
fetch("data:application/wasm;base64,AGFzbQEAAAABBgFgAX4BfwMCAQAHDgEKaTY0LnBvcGNudAAACggBBgAgAHunCwAKBG5hbWUCAwEAAA=="),
{}));
const instance = wasm.instance;
export const popcount = instance.exports['i64.popcnt'] as (v: bigint) => number;
export class BitSet {
#grow(){}
}
// module uncomment_me_to_fix {}
🙁 Actual behavior
Line 17 (export class BitSet) reports an error: Duplicate identifier 'BitSet'.(2300)
As far as I can see there's no duplicate identifier; suppressing that line with a @ts-expect-error produces a strange result that the exported BitSet is unusable when imported into a different module, whereupon Typescript reports:
Type 'import("./lib/bitset").BitSet' is not assignable to type 'import("./lib/bitset").BitSet'. Two different types with this name exist, but they are unrelated.
Property '#grow' in type 'BitSet' refers to a different member that cannot be accessed from within type 'BitSet'.ts(2719)
Uncommenting the empty module definition at the bottom of the file appears to collapse the superimposed wave function of BitSet, and renders the type singular again.
🙂 Expected behavior
To see neither error, whether or not there's a module in the same file.
Additional information about the issue
Hopefully, it's clear enough from the example what I'm hoping to do here with the top-level await; I deleted all the method bodies for brevity, so you'll have to trust me when I say popcount is a very useful primitive to have.
I did spend a fair bit of time looking for suggestions on whether I'm holding the tool wrong with the await ....; export class ... sequencing, but as far as I can tell that is how it's intended to be used. The fact that an unrelated (to my eye, anyway) expression later on in the file changes the compiler's report is what finally moved me to file an issue against tsc here.
Thanks for all your work on Typescript!
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
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.
Altre issue di microsoft/TypeScript
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
microsoft/TypeScript#64322 · 2 commenti · 1 reazione · 2 assegnatari ·
-
Possible Improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoft/TypeScript#64278 · 1 commento · 1 reazione ·
-
Docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
microsoft/TypeScript#64118 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
microsoft/TypeScript#64094 ·
-
Docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
microsoft/TypeScript#63959 · 5 commenti ·
Tutte le issue di microsoft/TypeScript
Issue simili
-
optimization optimization:agents-md-curator
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
blinklabs-io/bursa#904 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 commenti ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100