Closed garyo closed 3 years ago
If you try to push a plain userId to the data layer, you get a Typescript error that "event" is required:
userId
if (Vue.gtm.enabled()) { window.dataLayer?.push({userId: user?.uid || ''}) }
Object of type ... is not assignable to parameter of type 'DataLayerObject'. Property 'event' is missing... but is required in type 'DataLayerObject'.
I'm not an expert on this, but a simple fix that works for me is to make event optional at line 8 of plugin.d.ts, like this:
plugin.d.ts
export interface DataLayerObject extends Record<string, any> { event?: string; }
Info
Input
If you try to push a plain
userId
to the data layer, you get a Typescript error that "event" is required:Output or Error
Object of type ... is not assignable to parameter of type 'DataLayerObject'. Property 'event' is missing... but is required in type 'DataLayerObject'.
Additional Context
I'm not an expert on this, but a simple fix that works for me is to make event optional at line 8 of
plugin.d.ts
, like this: