From ec5a3736acf728a07f52847e16bf68f9dad501d2 Mon Sep 17 00:00:00 2001 From: Io Klarstrup Date: Mon, 9 Sep 2024 11:08:42 +0200 Subject: [PATCH] fix some incito kit types --- lib/kits/incito-publication/bootstrapper.ts | 16 +++++++++++----- lib/kits/incito-publication/viewer.ts | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/kits/incito-publication/bootstrapper.ts b/lib/kits/incito-publication/bootstrapper.ts index 84ba543d..b699c6fc 100644 --- a/lib/kits/incito-publication/bootstrapper.ts +++ b/lib/kits/incito-publication/bootstrapper.ts @@ -53,9 +53,9 @@ function getLocale() { interface BootstrapperInit { el: HTMLElement; - id: string; - apiKey: string; - coreUrl: string; + id?: string; + apiKey?: string; + coreUrl?: string; eventTracker: Tracker; } export default class Bootstrapper { @@ -82,7 +82,7 @@ export default class Bootstrapper { getFeatureLabels() { const regex = new RegExp(/tjek_audience=[^#&;+]+/); const match = regex.exec(location.href) || []; - let feature; + let feature: string[]; if (match.length > 0) { feature = @@ -127,6 +127,12 @@ export default class Bootstrapper { ) => void ) { try { + if (!this.options.id) { + throw new Error( + 'You need to supply a valid id to use Bootstrapper#fetch' + ); + } + const {0: details, 1: incito} = await Promise.all([ this.fetchDetails(this.options.id), this.fetchIncito(this.options.id) @@ -190,7 +196,7 @@ export default class Bootstrapper { callback ); - createViewer({details, incito}) { + createViewer({details, incito}: {details?: V2Catalog; incito: IIncito}) { const self = this; if (!incito) { diff --git a/lib/kits/incito-publication/viewer.ts b/lib/kits/incito-publication/viewer.ts index ec9d04ec..4f8d8ece 100644 --- a/lib/kits/incito-publication/viewer.ts +++ b/lib/kits/incito-publication/viewer.ts @@ -8,8 +8,8 @@ import './viewer.styl'; interface ViewerInit { incito: IIncito; - eventTracker: Tracker; - details: V2Catalog; + eventTracker?: Tracker; + details?: V2Catalog; } class Viewer extends MicroEvent { static Incito = Incito;