Plugin API: How to change a declaration?

This issue has been tracked since 2023-01-15.

Search terms

plugin, declaration, change, remove, update, unregister


I'm trying to make a plugin for typedoc to be able to document zod object types as if they were interfaces. For example, I want to treat the code

/** Some documentation! */
const SomeObject = z.object({
  /** Something */
  foo: z.string(),

/** More documentation! */
const OtherThing = SomeObject.extend({
  /** Other! */
  bar: z.number(),

export type SomeInterface = z.infer<typeof SomeObject>;
export type OtherInterface = z.infer<typeof OtherThing>;

As if it was written

/** Some documentation! */
export interface SomeInterface {
  /** Something */
  foo: string;

/** More documentation! */
export interface OtherInterface extends SomeInterface {
  /** Other! */
  bar: number,

Ideally I'd just use a typescript plugin for this, but those still aren't properly supported, so instead I'm trying to do it with a combination of a typedoc plugin and a .d.ts codemod. For the typedoc plugin though I'm a bit lost. I can't find a good guide on how to make a plugin. I found context.registerReflection(), which looks like it will work to create the phantom interfaces, but how can I unregister the actual types? Or is there a better way of doing this?

Gerrit0 wrote this answer on 2023-02-04

project.removeReflection is what you're looking for, there aren't really any guides on creating a plugin, just other plugins to use as examples.

I think creating new reflections is probably the way to go with this, I'd recommend context.createDeclarationReflection, which should get comments correctly if you give it the symbol of the appropriate property you're creating.

More Details About Repo
Owner Name TypeStrong
Repo Name typedoc
Full Name TypeStrong/typedoc
Language TypeScript
Created Date 2014-05-24
Updated Date 2023-03-19
Star Count 6487
Watcher Count 68
Fork Count 639
Issue Count 48


Issue Title Created Date Updated Date