Nanashi.
Nanashi.6mo ago

Good way to re-export with document?

I have a library, and I want to rename my class. I want to keep backward compatibility, but I don't want new users to use it, so I want to make it as deprecated. Are there any good way to do re-export class, but with additional jsdoc?
3 Replies
Nanashi.
Nanashi.OP6mo ago
These are what I did and I got:
export * from "./reader.ts";
export * from "./writer.ts";

/**
* Alias of BinaryReader, for compatibility with the old name.
* @deprecated Use BinaryReader instead.
*/
export { BinaryReader as BinarySeeker } from "./reader.ts";

/**
* Alias of BinaryReader, for compatibility with the old name.
* @deprecated Use BinaryReader instead.
*/
export { BinaryReader as default } from "./reader.ts";
export * from "./reader.ts";
export * from "./writer.ts";

/**
* Alias of BinaryReader, for compatibility with the old name.
* @deprecated Use BinaryReader instead.
*/
export { BinaryReader as BinarySeeker } from "./reader.ts";

/**
* Alias of BinaryReader, for compatibility with the old name.
* @deprecated Use BinaryReader instead.
*/
export { BinaryReader as default } from "./reader.ts";
No description
Deno AI Helper
Deno AI Helper6mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on your message, you can re-export a class with additional JSDoc comments to mark it as deprecated. Here's an example of how you might do it:
// Assuming the original class is named `OldClass`
export class NewClass {
// ... your class implementation
}

/** @deprecated Use NewClass instead. */
export { NewClass as OldClass };
// Assuming the original class is named `OldClass`
export class NewClass {
// ... your class implementation
}

/** @deprecated Use NewClass instead. */
export { NewClass as OldClass };
In this example, NewClass is the new name of your class, and you're re-exporting it as OldClass with a JSDoc comment indicating that it's deprecated. This way, you can signal to your users that they should use NewClass instead of OldClass. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. If you're using an IDE or a code editor that supports JSDoc, it should be able to pick up on the @deprecated tag and warn users accordingly.
Nanashi.
Nanashi.OP6mo ago
Did not work
export * from "./reader.ts";
export * from "./writer.ts";

import { BinaryReader } from "./reader.ts";

/**
* Alias for BinaryReader, for backwards compatibility.
* @deprecated Use BinaryReader instead.
*/
export { BinaryReader as BinarySeeker };
export * from "./reader.ts";
export * from "./writer.ts";

import { BinaryReader } from "./reader.ts";

/**
* Alias for BinaryReader, for backwards compatibility.
* @deprecated Use BinaryReader instead.
*/
export { BinaryReader as BinarySeeker };
No description

Did you find this page helpful?