File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed
fixtures/oxc-tsconfigs/decorator-metadata Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "experimentalDecorators" : true ,
4+ "emitDecoratorMetadata" : true
5+ }
6+ }
Original file line number Diff line number Diff line change @@ -156,6 +156,28 @@ describe('transformWithOxc', () => {
156156 expect ( actual ) . toBe ( defineForClassFieldsFalseTransformedCode )
157157 } )
158158 } )
159+
160+ test ( 'supports emitDecoratorMetadata: true' , async ( ) => {
161+ const result = await transformWithOxc (
162+ `
163+ function LogMethod(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) {
164+ console.log(target, propertyKey, descriptor);
165+ }
166+
167+ class Demo {
168+ @LogMethod
169+ public foo(bar: number) {}
170+ }
171+
172+ const demo = new Demo();
173+ ` ,
174+ path . resolve (
175+ import . meta. dirname ,
176+ './fixtures/oxc-tsconfigs/decorator-metadata/bar.ts' ,
177+ ) ,
178+ )
179+ expect ( result ?. code ) . toContain ( '_decorateMetadata("design:type"' )
180+ } )
159181} )
160182
161183describe ( 'renderChunk' , ( ) => {
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ type TSConfigJSON = {
6969 preserveValueImports ?: boolean
7070 target ?: string
7171 useDefineForClassFields ?: boolean
72+ emitDecoratorMetadata ?: boolean
7273 verbatimModuleSyntax ?: boolean
7374 }
7475 [ key : string ] : any
Original file line number Diff line number Diff line change @@ -148,6 +148,13 @@ export async function transformWithOxc(
148148 resolvedOptions . decorator ??= { }
149149 resolvedOptions . decorator . legacy = experimentalDecorators
150150 }
151+ const emitDecoratorMetadata =
152+ loadedCompilerOptions . emitDecoratorMetadata
153+ if ( emitDecoratorMetadata !== undefined ) {
154+ resolvedOptions . decorator ??= { }
155+ resolvedOptions . decorator . emitDecoratorMetadata =
156+ emitDecoratorMetadata
157+ }
151158 }
152159
153160 /**
You can’t perform that action at this time.
0 commit comments