Multi-line top-level `await` causes duplicate declaration error
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
- Área
- compilers
Línea de trabajo
Comienza con la reproducción enlazada en TypeScript Playground e investiga el análisis de top-level-await y de módulos del compilador en torno al diagnóstico duplicado de BitSet informado. Se habrá terminado cuando el ejemplo no produzca ni el error de identificador duplicado ni el error de incompatibilidad de miembros privados, con o sin la declaración de módulo vacía.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
🔎 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!
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/TypeScript
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
microsoft/TypeScript#64322 · 2 comentarios · 1 reacción · 2 asignados ·
-
Possible Improvement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/TypeScript#64278 · 1 comentario · 1 reacción ·
-
Docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
microsoft/TypeScript#64118 · 1 comentario ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
microsoft/TypeScript#64094 ·
-
Docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
microsoft/TypeScript#63959 · 5 comentarios ·
Todos los issues de microsoft/TypeScript
Issues similares
-
kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
kubernetes-sigs/prow#953 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
caddyserver/caddy#8046 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
-
L1 recommended for recruits
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
area/entangle bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100