fix(jsdoc-doclet): don't track unused doclets by properties like longname

This commit is contained in:
Jeff Williams 2023-11-12 13:05:02 -08:00
parent 5bbacd2ec7
commit ba70bb4d6b
No known key found for this signature in database
2 changed files with 15 additions and 1 deletions

View File

@ -202,7 +202,11 @@ export class DocletStore {
newKey = doclet[requestedProp];
}
if (wasVisible && oldKey) {
// If the doclet is no longer visible, we must always remove it from the set, using whatever key
// we have.
if (wasVisible && !isVisible) {
removeFromSet(map, oldKey ?? newKey, doclet);
} else if (wasVisible && oldKey) {
removeFromSet(map, oldKey, doclet);
}
if (isVisible && newKey) {

View File

@ -884,6 +884,16 @@ describe('@jsdoc/doclet/lib/doclet-store', () => {
expect(store.allDocletsByLongname.get(true)).toBeUndefined();
});
it('does not track a doclet by longname if it is no longer visible', () => {
const doclet = makeDoclet(['@class', '@memberof foo', '@name Bar']);
expect(store.docletsByLongname.get('foo.Bar')).toHave(doclet);
doclet.undocumented = true;
expect(store.docletsByLongname.get('foo.Bar')).toBeUndefined();
});
});
describe('`memberof`', () => {