1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix typings

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2020-11-20 15:03:46 -05:00
parent fbb895c816
commit 9847d1ef78
2 changed files with 8 additions and 6 deletions

View File

@ -9,11 +9,12 @@ export class BaseRegistry<T> {
return this.items.toJS();
}
add(items: T[], ext?: LensExtension): () => void; // allow method overloading with required "ext"
add(items: T | T[], ext?: LensExtension): () => void; // allow method overloading with required "ext"
@action
add(items: T[]) {
this.items.push(...items);
return () => this.remove(...items);
add(items: T | T[]) {
const itemArray: T[] = Array.isArray(items) ? items : [items];
this.items.push(...itemArray);
return () => this.remove(...itemArray);
}
@action

View File

@ -62,9 +62,10 @@ export function getExtensionPageUrl<P extends object>({ extensionId, pageId = ""
export class PageRegistry extends BaseRegistry<RegisteredPage> {
@action
add(items: PageRegistration[], ext: LensExtension) {
add(items: PageRegistration | PageRegistration[], ext: LensExtension) {
const itemArray = Array.isArray(items) ? items : [items];
try {
const pages = items.map(page => ({
const pages = itemArray.map(page => ({
...page,
extensionId: ext.name,
routePath: getExtensionPageUrl({ extensionId: ext.name, pageId: page.id ?? page.routePath }),