You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Found a behavior difference beween pnpm dev and pnpm preview, when referencing a state property as a default constructor arg.
I do realise what I did is unorthodox and unnecessary, but it's interesting that esbuild breaks it nonetheless
<script>
classA { a =$state("test");constructor(init=/* this causes it to fail: */this.a){this.a= init; } }consta=newA();
</script>
{a.a}
Reproduction
scaffold a basic sveltekit app
npx sv create
put this in ./src/routes/+page.svelte
<script>
classA { a =$state("test");constructor(init=/* this causes it to fail: */this.a){this.a= init; } }consta=newA();
</script>
{a.a}
run dev server and observe it works fine
pnpm dev
run a build and preview, observe browser console error
pnpm build
pnpm preview
Logs
2.DfF_Z-xm.js:1 Uncaught (in promise) TypeError: Cannot read from private field
at n (2.DfF_Z-xm.js:1:17)
at c (2.DfF_Z-xm.js:1:56)
at r (2.DfF_Z-xm.js:1:87)
at get a (2.DfF_Z-xm.js:1:534)
at new a (2.DfF_Z-xm.js:1:485)
at q (2.DfF_Z-xm.js:1:595)
at app.BtHtryw3.js:2:6003
at app.BtHtryw3.js:2:1529
at an (DEKecDdA.js:1:11051)
at bt (DEKecDdA.js:1:11936)
Describe the bug
Found a behavior difference beween
pnpm dev
andpnpm preview
, when referencing a state property as a default constructor arg.I do realise what I did is unorthodox and unnecessary, but it's interesting that esbuild breaks it nonetheless
Reproduction
./src/routes/+page.svelte
Logs
2.DfF_Z-xm.js:1 Uncaught (in promise) TypeError: Cannot read from private field at n (2.DfF_Z-xm.js:1:17) at c (2.DfF_Z-xm.js:1:56) at r (2.DfF_Z-xm.js:1:87) at get a (2.DfF_Z-xm.js:1:534) at new a (2.DfF_Z-xm.js:1:485) at q (2.DfF_Z-xm.js:1:595) at app.BtHtryw3.js:2:6003 at app.BtHtryw3.js:2:1529 at an (DEKecDdA.js:1:11051) at bt (DEKecDdA.js:1:11936)
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: