Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeDoc 0.16.4: project.removeReflection does not fully remove a reflection #1176

Closed
1 task done
christopherthielen opened this issue Jan 15, 2020 · 3 comments
Closed
1 task done
Labels
bug Functionality does not match expectation

Comments

@christopherthielen
Copy link
Contributor

christopherthielen commented Jan 15, 2020

Expected Behavior

Calling ProjectReflection.removeReflection() should remove the reflection from the project

Actual Behavior

A reference to the removed reflection remains in the ProjectReflection.reflections array. This array is still used in some typedoc code to iterate reflections.

If --json is used, the reflection does not appear in the output. However, the reflection appears in the output if --out dist is used.

Steps to reproduce the bug

Create a plugin that deletes reflections, then generate HTML docs. Note that the deleted modules appear in the module list table of contents.

./delete-this-reflection.ts

export class Test {
  public number = 1;
  private string = "asfff";
  method(arg: number) { }
}

./delete-reflections-plugin.js

const { Converter } = require('typedoc/dist/lib/converter');
module.exports = function load(host) {
  const reflections = [];
  const app = host.application;

  app.converter.on(Converter.EVENT_CREATE_DECLARATION, (context, reflection) => {
    reflections.push(reflection);
  });

  app.converter.on(Converter.EVENT_RESOLVE_BEGIN, context => {
    reflections.forEach(reflection => context.project.removeReflection(reflection));
  });
}

Then run this command:

npm init -y
npm install typedoc@0.16.4
./node_modules/.bin/typedoc --plugin ../../../../../delete-reflections-plugin ./delete-this-reflection.ts --out dist

Note that the deleted Module reflection still appears in the table of contents:

Screen Shot 2020-01-15 at 1 05 36 PM

Environment

  • Typedoc version: 0.16.4
  • Node.js version: 10.15.1
  • OS: MacOS Catalina 10.15.2

Other details

I encountered this while trying to update typescript-plugin-external-module-name plugin to support 0.16.4

@christopherthielen christopherthielen added the bug Functionality does not match expectation label Jan 15, 2020
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jan 15, 2020

Thanks for the reproduction! Should be an easy fix.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jan 16, 2020

Fixed in 0.16.6

@christopherthielen
Copy link
Contributor Author

wow thanks! so fast :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants