oxc/crates/oxc_codegen/tests/integration/jsdoc.rs
camc314 4a99372c14 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. 🙂
2024-09-24 01:12:57 +00:00

99 lines
1.7 KiB
Rust

use crate::snapshot;
#[test]
fn comment() {
let cases = vec![
r"
/** This is a description of the foo function. */
function foo() {
}
/**
* Represents a book.
* @constructor
* @param {string} title - The title of the book.
* @param {string} author - The author of the book.
*/
function Book(title, author) {
}
/** Class representing a point. */
class Point {
/**
* Create a point.
* @param {number} x - The x value.
* @param {number} y - The y value.
*/
constructor(x, y) {
}
/**
* Get the x value.
* @return {number} The x value.
*/
getX() {
}
/**
* Get the y value.
* @return {number} The y value.
*/
getY() {
}
/**
* Convert a string containing two comma-separated numbers into a point.
* @param {string} str - The string containing two comma-separated numbers.
* @return {Point} A Point object.
*/
static fromString(str) {
}
}
/** Class representing a point. */
const Point = class {
}
/**
* Shirt module.
* @module my/shirt
*/
/** Button the shirt. */
exports.button = function() {
};
/** Unbutton the shirt. */
exports.unbutton = function() {
};
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);
}