"Cannot access '_A' before initialization" when using static properties and a static initializer #13500
Closed
7 tasks done
Labels
bug: upstream
Bug in a dependency of Vite
Describe the bug
When using both a static initializer block and static properties in a typescript class
A
, the compiled result produces an error:Uncaught ReferenceError: Cannot access '_A' before initialization
.This is the class in question:
And vite compiles this to:
Now this may very well be an upstream problem, but I wasn't able to figure out where it is caused. It seems that esbuild (with what little I understand of it) will produce correct results, either by compiling the static initializer into an IIFE (target es2020) or by keeping both constructs as they are (target esnext).
Maybe someone here can point me into the right direction? Maybe there's even a way to get this to work without having to wait for upstream fixes to land?
Reproduction
https://stackblitz.com/edit/vitejs-vite-xghabj?file=a.ts
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: