From b7a2c88a69fe1be1f4dec761a75d65b342284fe5 Mon Sep 17 00:00:00 2001 From: David First Date: Thu, 11 Apr 2024 15:19:37 -0400 Subject: [PATCH] fix, avoid using instanceof to find a component-issue --- components/component-issues/issues-list.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/components/component-issues/issues-list.ts b/components/component-issues/issues-list.ts index 5570f49c202e..5d80ec4cbdaa 100644 --- a/components/component-issues/issues-list.ts +++ b/components/component-issues/issues-list.ts @@ -90,13 +90,11 @@ export class IssuesList { this._issues = this._issues.filter((issue) => issue.constructor.name !== IssueClass.name); } - /** - * Use getIssueByName to prevent issues when getting different instances while using both bit from bvm and from the repo - * @param IssueClass - * @returns - */ getIssue(IssueClass: { new (): T }): T | undefined { - return this._issues.find((issue) => issue instanceof IssueClass) as T | undefined; + // don't use instanceof, e.g. `this._issues.find((issue) => issue instanceof IssueClass)` + // the "component-issues" package can come from different sources, so the "instanceof" won't work. + // use only getIssueByName for this. + return this.getIssueByName(IssueClass.name as IssuesNames); } getIssueByName(issueType: IssuesNames): T | undefined {