File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -378,6 +378,11 @@ describe('transformWithEsbuild', () => {
378
378
} )
379
379
expect ( actual ) . toBe ( defineForClassFieldsTrueTransformedCode )
380
380
} )
381
+
382
+ test ( 'target: es2022 and tsconfig.target: undefined => false' , async ( ) => {
383
+ const actual = await transformClassCode ( 'es2022' , { } )
384
+ expect ( actual ) . toBe ( defineForClassFieldsFalseTransformedCode )
385
+ } )
381
386
} )
382
387
} )
383
388
Original file line number Diff line number Diff line change @@ -132,6 +132,16 @@ export async function transformWithEsbuild(
132
132
...tsconfigRaw ?. compilerOptions ,
133
133
}
134
134
135
+ // esbuild uses `useDefineForClassFields: true` when `tsconfig.compilerOptions.target` isn't declared
136
+ // but we want `useDefineForClassFields: false` when `tsconfig.compilerOptions.target` isn't declared
137
+ // to align with the TypeScript's behavior
138
+ if (
139
+ compilerOptions . useDefineForClassFields === undefined &&
140
+ compilerOptions . target === undefined
141
+ ) {
142
+ compilerOptions . useDefineForClassFields = false
143
+ }
144
+
135
145
// esbuild uses tsconfig fields when both the normal options and tsconfig was set
136
146
// but we want to prioritize the normal options
137
147
if ( options ) {
You can’t perform that action at this time.
0 commit comments