Closed hi-ogawa closed 2 months ago
Related: https://github.com/evanw/esbuild/issues/3911, https://github.com/vitejs/vite/issues/18105
Full code to compare with tsc is here https://github.com/hi-ogawa/reproductions/tree/main/vite-18105-decorator-useDefineForClassFields
Here is a part of the code on esbuild try
function testDecorator(_value: unknown, context: DecoratorContext) { if (context.kind === "field") { return () => "dec-ok"; } } class DecClass { @testDecorator decInit = "init"; @testDecorator decNoInit: any; } console.log(new DecClass()) // esbuild: DecClass { decInit: 'dec-ok' } // tsc: DecClass { decInit: 'dec-ok', decNoInit: 'dec-ok' }
Vite uses useDefineForClassFields: false for esbuild transform when users don't not explicitly set, but this specific decorator usages being not working seems to lead to a bit surprising behavior.
useDefineForClassFields: false
Related: https://github.com/evanw/esbuild/issues/3911, https://github.com/vitejs/vite/issues/18105
Full code to compare with tsc is here https://github.com/hi-ogawa/reproductions/tree/main/vite-18105-decorator-useDefineForClassFields
Here is a part of the code on esbuild try
Vite uses
useDefineForClassFields: false
for esbuild transform when users don't not explicitly set, but this specific decorator usages being not working seems to lead to a bit surprising behavior.