fix typings

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

No files matched your search

+5 -4
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
+3 -2
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 }),