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:
parent
fbb895c816
commit
9847d1ef78
@ -9,11 +9,12 @@ export class BaseRegistry<T> {
|
|||||||
return this.items.toJS();
|
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
|
@action
|
||||||
add(items: T[]) {
|
add(items: T | T[]) {
|
||||||
this.items.push(...items);
|
const itemArray: T[] = Array.isArray(items) ? items : [items];
|
||||||
return () => this.remove(...items);
|
this.items.push(...itemArray);
|
||||||
|
return () => this.remove(...itemArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|||||||
@ -62,9 +62,10 @@ export function getExtensionPageUrl<P extends object>({ extensionId, pageId = ""
|
|||||||
|
|
||||||
export class PageRegistry extends BaseRegistry<RegisteredPage> {
|
export class PageRegistry extends BaseRegistry<RegisteredPage> {
|
||||||
@action
|
@action
|
||||||
add(items: PageRegistration[], ext: LensExtension) {
|
add(items: PageRegistration | PageRegistration[], ext: LensExtension) {
|
||||||
|
const itemArray = Array.isArray(items) ? items : [items];
|
||||||
try {
|
try {
|
||||||
const pages = items.map(page => ({
|
const pages = itemArray.map(page => ({
|
||||||
...page,
|
...page,
|
||||||
extensionId: ext.name,
|
extensionId: ext.name,
|
||||||
routePath: getExtensionPageUrl({ extensionId: ext.name, pageId: page.id ?? page.routePath }),
|
routePath: getExtensionPageUrl({ extensionId: ext.name, pageId: page.id ?? page.routePath }),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user