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', () => {
156
156
expect ( actual ) . toBe ( defineForClassFieldsFalseTransformedCode )
157
157
} )
158
158
} )
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
+ } )
159
181
} )
160
182
161
183
describe ( 'renderChunk' , ( ) => {
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ type TSConfigJSON = {
69
69
preserveValueImports ?: boolean
70
70
target ?: string
71
71
useDefineForClassFields ?: boolean
72
+ emitDecoratorMetadata ?: boolean
72
73
verbatimModuleSyntax ?: boolean
73
74
}
74
75
[ key : string ] : any
Original file line number Diff line number Diff line change @@ -148,6 +148,13 @@ export async function transformWithOxc(
148
148
resolvedOptions . decorator ??= { }
149
149
resolvedOptions . decorator . legacy = experimentalDecorators
150
150
}
151
+ const emitDecoratorMetadata =
152
+ loadedCompilerOptions . emitDecoratorMetadata
153
+ if ( emitDecoratorMetadata !== undefined ) {
154
+ resolvedOptions . decorator ??= { }
155
+ resolvedOptions . decorator . emitDecoratorMetadata =
156
+ emitDecoratorMetadata
157
+ }
151
158
}
152
159
153
160
/**
You can’t perform that action at this time.
0 commit comments