fix(codegen): print jsdoc comments for TSEnumMembers (#6007)

closes #6006

Boshen/Dunqing please feel free to take over this PR. it's a bit outside what i normally work on. 🙂
This commit is contained in:
camc314 2024-09-24 01:12:57 +00:00
parent 5ae3f364e9
commit 4a99372c14
3 changed files with 65 additions and 2 deletions

View file

@ -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),

View file

@ -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);

View file

@ -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',
}