Skip to content

TypeScript issue with 'third-party-capital' and google-analytics (despite not using them) #135

Description

@Dino-Kupinic

I am trying to use Nuxt Scripts for Microsoft Clarity.

Nuxt 3.12.3
Nuxt Scripts 0.6.2
TypeScript 5.5.3
vue-tsc 2.0.26

My nuxt config:

$production: {scripts: {registry: {clarity: true,},},},runtimeConfig: {githubToken: "",public: {scripts: {clarity: {id: "",},},},},// ...typescript: {typeCheck: true,strict: true,tsConfig: {compilerOptions: {baseUrl: ".",},},},// ...

Starting dev server:

/Users/dinokupinic/.nvm/versions/node/v20.10.0/bin/pnpm run dev
> dinokupinic@ dev /Users/dinokupinic/Programming/TypeScript/dinokupinic
> nuxt dev
Nuxt 3.12.3 with Nitro 2.9.7 9:11:37 PM
9:11:38 PM
➜ Local: http://localhost:3000/
➜ Network: use --host to expose
ℹ Using Tailwind CSS from ~/assets/css/tailwind.css nuxt:tailwindcss 9:11:39 PM
➜ DevTools: press Shift + Option + D in the browser (v1.3.9) 9:11:42 PM
ℹ Tailwind Viewer: http://localhost:3000/_tailwind/ nuxt:tailwindcss 9:11:42 PM
✔ Nuxt Nitro server built in 2458 ms nitro 9:11:47 PM
ℹ Vite server warmed up in 6258ms 9:11:50 PM
ℹ ✨ new dependencies optimized: date-fns 9:11:50 PM
ℹ ✨ optimized dependencies changed. reloading 9:11:50 PM
ℹ Vite client warmed up in 6852ms 9:11:50 PM
ERROR 9:12:00 PM
ERROR(vue-tsc) Cannot find module 'third-party-capital' or its corresponding type declarations.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-analytics.ts:4:41
2 | import { useRegistryScript } from '#nuxt-scripts-utils'
3 | import type { RegistryScriptInput } from '#nuxt-scripts'
> 4 | import type { GoogleAnalyticsApi } from "third-party-capital";
| ^^^^^^^^^^^^^^^^^^^^^
5 | import { object, any } from "#nuxt-scripts-validator";
6 | const OptionSchema = object({id: any()})
7 |
ERROR(vue-tsc) Property 'dataLayer' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-analytics.ts:22:38
20 | scriptOptions: {
21 | use: () => {
> 22 | return { dataLayer: window.dataLayer, gtag: window.gtag };
| ^^^^^^^^^
23 | },
24 | stub: import.meta.client ? undefined : ({ fn }) => {
25 | return fn === "dataLayer" ? [] : void 0;
ERROR(vue-tsc) Property 'gtag' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-analytics.ts:22:62
20 | scriptOptions: {
21 | use: () => {
> 22 | return { dataLayer: window.dataLayer, gtag: window.gtag };
| ^^^^
23 | },
24 | stub: import.meta.client ? undefined : ({ fn }) => {
25 | return fn === "dataLayer" ? [] : void 0;
ERROR(vue-tsc) Property 'dataLayer' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-analytics.ts:29:68
27 | ...({"tagPriority":1})
28 | },
> 29 | clientInit: import.meta.server ? undefined : () => {window.dataLayer=window.dataLayer||[];window.gtag=function gtag(){window.dataLayer.push(arguments);};window.gtag('js',new Date());window.gtag('config',options.id)},
| ^^^^^^^^^
30 | }), _options)
31 | }
ERROR(vue-tsc) Property 'dataLayer' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-analytics.ts:29:85
27 | ...({"tagPriority":1})
28 | },
> 29 | clientInit: import.meta.server ? undefined : () => {window.dataLayer=window.dataLayer||[];window.gtag=function gtag(){window.dataLayer.push(arguments);};window.gtag('js',new Date());window.gtag('config',options.id)},
| ^^^^^^^^^
30 | }), _options)
31 | }
ERROR(vue-tsc) Property 'gtag' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-analytics.ts:29:106
27 | ...({"tagPriority":1})
28 | },
> 29 | clientInit: import.meta.server ? undefined : () => {window.dataLayer=window.dataLayer||[];window.gtag=function gtag(){window.dataLayer.push(arguments);};window.gtag('js',new Date());window.gtag('config',options.id)},
| ^^^^
30 | }), _options)
31 | }
ERROR(vue-tsc) Property 'dataLayer' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-analytics.ts:29:134
27 | ...({"tagPriority":1})
28 | },
> 29 | clientInit: import.meta.server ? undefined : () => {window.dataLayer=window.dataLayer||[];window.gtag=function gtag(){window.dataLayer.push(arguments);};window.gtag('js',new Date());window.gtag('config',options.id)},
| ^^^^^^^^^
30 | }), _options)
31 | }
ERROR(vue-tsc) Property 'gtag' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-analytics.ts:29:169
27 | ...({"tagPriority":1})
28 | },
> 29 | clientInit: import.meta.server ? undefined : () => {window.dataLayer=window.dataLayer||[];window.gtag=function gtag(){window.dataLayer.push(arguments);};window.gtag('js',new Date());window.gtag('config',options.id)},
| ^^^^
30 | }), _options)
31 | }
ERROR(vue-tsc) Property 'gtag' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-analytics.ts:29:198
27 | ...({"tagPriority":1})
28 | },
> 29 | clientInit: import.meta.server ? undefined : () => {window.dataLayer=window.dataLayer||[];window.gtag=function gtag(){window.dataLayer.push(arguments);};window.gtag('js',new Date());window.gtag('config',options.id)},
| ^^^^
30 | }), _options)
31 | }
ERROR(vue-tsc) Cannot find module 'third-party-capital' or its corresponding type declarations.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-tag-manager.ts:4:42
2 | import { useRegistryScript } from '#nuxt-scripts-utils'
3 | import type { RegistryScriptInput } from '#nuxt-scripts'
> 4 | import type { GoogleTagManagerApi } from "third-party-capital";
| ^^^^^^^^^^^^^^^^^^^^^
5 | import { object, any } from "#nuxt-scripts-validator";
6 | const OptionSchema = object({id: any()})
7 |
ERROR(vue-tsc) Property 'dataLayer' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-tag-manager.ts:22:38
20 | scriptOptions: {
21 | use: () => {
> 22 | return { dataLayer: window.dataLayer, google_tag_manager: window.google_tag_manager };
| ^^^^^^^^^
23 | },
24 | stub: import.meta.client ? undefined : ({ fn }) => {
25 | return fn === "dataLayer" ? [] : void 0;
ERROR(vue-tsc) Property 'google_tag_manager' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-tag-manager.ts:22:76
20 | scriptOptions: {
21 | use: () => {
> 22 | return { dataLayer: window.dataLayer, google_tag_manager: window.google_tag_manager };
| ^^^^^^^^^^^^^^^^^^
23 | },
24 | stub: import.meta.client ? undefined : ({ fn }) => {
25 | return fn === "dataLayer" ? [] : void 0;
ERROR(vue-tsc) Property 'dataLayer' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-tag-manager.ts:29:68
27 | ...({"tagPriority":1})
28 | },
> 29 | clientInit: import.meta.server ? undefined : () => {window.dataLayer=window.dataLayer||[];window.dataLayer.push({'gtm.start':new Date().getTime(),event:'gtm.js'});},
| ^^^^^^^^^
30 | }), _options)
31 | }
ERROR(vue-tsc) Property 'dataLayer' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-tag-manager.ts:29:85
27 | ...({"tagPriority":1})
28 | },
> 29 | clientInit: import.meta.server ? undefined : () => {window.dataLayer=window.dataLayer||[];window.dataLayer.push({'gtm.start':new Date().getTime(),event:'gtm.js'});},
| ^^^^^^^^^
30 | }), _options)
31 | }
ERROR(vue-tsc) Property 'dataLayer' does not exist on type 'Window & typeof globalThis'.
FILE /Users/dinokupinic/Programming/TypeScript/dinokupinic/.nuxt/nuxt-scripts/tpc/google-tag-manager.ts:29:106
27 | ...({"tagPriority":1})
28 | },
> 29 | clientInit: import.meta.server ? undefined : () => {window.dataLayer=window.dataLayer||[];window.dataLayer.push({'gtm.start':new Date().getTime(),event:'gtm.js'});},
| ^^^^^^^^^
30 | }), _options)
31 | }
[vue-tsc] Found 15 errors. Watching for file changes.

is there a fix for this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions