MatteoGabriele/vue-gtag-next

Type issues when building with vue-tsc

Opened this issue · 1 comments

If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.

Description

Using vue-gtag-next with Vue 3, VueRouter 4, TypeScript and Vite. Running the Vite dev server works fine but when I do a build I get the following errors.

> vue-tsc --noEmit && vite build

node_modules/vue-gtag-next/vue-gtag-next.d.ts:2:25 - error TS2307: Cannot find module 'vue-router/types/router' or its corresponding type declarations.

2   import { Route } from 'vue-router/types/router';
                          ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/vue-gtag-next/vue-gtag-next.d.ts:306:39 - error TS2709: Cannot use namespace 'VueRouter' as a type.

306   export function trackRouter(router: VueRouter, options?: RouterOptions): void;
                                          ~~~~~~~~~

Found 2 errors.

Expected behavior

Package should not encounter type issues when building.

Actual behavior

Type issues surrounding vue-router and trackRouter occur.

Environment

Run this command in the project folder and fill in their results:

npm ls vue-gtag:

super-auto-pets-cheatsheet@0.0.0 /home/soviut/projects/super-auto-pets-cheatsheet
└── vue-gtag-next@1.14.0

Then, specify:

  1. Operating system: Ubuntu 20
  2. Browser and version: Chrome latest

Reproducible Demo

Please take the time to create a new app that reproduces the issue or at least some code example

Demonstrable issues gets fixed faster.

For the time being, I've worked around this by changing my build script in package.json from this

"build": "vue-tsc --noEmit && vite build",

to this

"build": "vite build",

It's not ideal but I get enough type checking from Volar in VSCode that I can live with it until vue-gtag-next targets VueRouter 4.