diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index f72ba077e06f2..7ed2ab60584e0 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -3551,6 +3551,7 @@ impl<'a> Gen for TSEnumDeclaration<'a> { impl<'a> Gen for TSEnumMember<'a> { fn gen(&self, p: &mut Codegen, ctx: Context) { + p.print_leading_comments(self.span.start); match &self.id { TSEnumMemberName::StaticIdentifier(decl) => decl.print(p, ctx), TSEnumMemberName::StaticStringLiteral(decl) => decl.print(p, ctx), diff --git a/crates/oxc_codegen/tests/integration/jsdoc.rs b/crates/oxc_codegen/tests/integration/jsdoc.rs index 9619151588911..2f5d625382b55 100644 --- a/crates/oxc_codegen/tests/integration/jsdoc.rs +++ b/crates/oxc_codegen/tests/integration/jsdoc.rs @@ -71,7 +71,28 @@ this.Book = function(title) { /** The title of the book. */ this.title = title; } - ", +// https://github.com/oxc-project/oxc/issues/6006 +export enum DefinitionKind { + /** + * Definition is a referenced variable. + * + * @example defineSomething(foo) + */ + Reference = 'Reference', + /** + * Definition is a `ObjectExpression`. + * + * @example defineSomething({ ... }) + */ + Object = 'Object', + /** + * Definition is TypeScript interface. + * + * @example defineSomething<{ ... }>() + */ + TS = 'TS', +} +", ]; snapshot("jsodc", &cases); diff --git a/crates/oxc_codegen/tests/integration/snapshots/jsodc.snap b/crates/oxc_codegen/tests/integration/snapshots/jsodc.snap index f1b3b72d91c12..93f07fff3e2da 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/jsodc.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/jsodc.snap @@ -70,7 +70,28 @@ this.Book = function(title) { /** The title of the book. */ this.title = title; } - +// https://github.com/oxc-project/oxc/issues/6006 +export enum DefinitionKind { + /** + * Definition is a referenced variable. + * + * @example defineSomething(foo) + */ + Reference = 'Reference', + /** + * Definition is a `ObjectExpression`. + * + * @example defineSomething({ ... }) + */ + Object = 'Object', + /** + * Definition is TypeScript interface. + * + * @example defineSomething<{ ... }>() + */ + TS = 'TS', +} + ---------- /** This is a description of the foo function. */ function foo() {} @@ -119,3 +140,23 @@ this.Book = function(title) { /** The title of the book. */ this.title = title; }; +export enum DefinitionKind { + /** + * Definition is a referenced variable. + * + * @example defineSomething(foo) + */ + Reference = 'Reference', + /** + * Definition is a `ObjectExpression`. + * + * @example defineSomething({ ... }) + */ + Object = 'Object', + /** + * Definition is TypeScript interface. + * + * @example defineSomething<{ ... }>() + */ + TS = 'TS', +}