Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/script/src/runtime/registry/google-tag-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,17 @@ export interface GoogleTagManagerApi {

/**
* Enhanced window type with GTM
*
* `dataLayer` is deliberately NOT declared globally. Its name is configurable through the
* `l` / `dataLayer` options, so `window.dataLayer` is not guaranteed to exist, and declaring it
* here makes this package irreconcilable with any other package that declares `Window.dataLayer`
* (for example `@gtm-support/core`, used by `@gtm-support/vue-gtm`): the two declarations cannot
* merge, so consumers of both get an unsuppressable TS2430 at every one of their own `Window`
* augmentations. Read it through the typed proxy returned by `useScriptGoogleTagManager()`
* instead, which is also the only access path that respects a custom dataLayer name.
*/
declare global {
interface Window extends GoogleTagManagerApi {}
interface Window extends Pick<GoogleTagManagerApi, 'google_tag_manager'> {}
}

export { GoogleTagManagerOptions }
Expand Down
Loading