-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
svelte-check give "cannot find name 'gtag'" upon upgrading to 2.56.1 from 2.55.0 #15669
Copy link
Copy link
Closed
Closed
Copy link
Labels
Description
Describe the bug
We have a component like
<script lang="ts">
import { page } from '$app/state';
$: {
if (typeof gtag !== 'undefined') {
gtag('config', 'AW-redacted', {
page_title: document.title,
page_path: page.url.pathname
});
}
}
</script>
<svelte:head>
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-redacted">
</script>
<script nonce="foobar">
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'AW-redacted');
</script>
</svelte:head>This component was last touched many revisions/months ago. I was prompted to upgrade svelte kit because nom audit was failing this morning. Now svelte-check is failing at this component. I believe a similar issue was posted 5 hours ago.
Reproduction
Include above component in the app
Logs
redacted/front-end/src/comp/Analytics.svelte:5:7
Error: Cannot find name 'gtag'. (ts)
if (typeof gtag !== 'undefined') {
gtag('config', 'AW-redacted', {
page_title: document.title,`
System Info
System:
OS: macOS 26.3.1
CPU: (8) arm64 Apple M2
Memory: 985.78 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.14.0 - /Users/me/.nvm/versions/node/v24.14.0/bin/node
npm: 11.9.0 - /Users/me/.nvm/versions/node/v24.14.0/bin/npm
Browsers:
Chrome: 146.0.7680.178
Firefox: 148.0.2
Safari: 26.3.1
npmPackages:
@sveltejs/adapter-auto: ^6.0.0 => 6.1.1
@sveltejs/adapter-static: ^3.0.8 => 3.0.10
@sveltejs/kit: ^2.47.3 => 2.56.1
@sveltejs/vite-plugin-svelte: ^5.1.1 => 5.1.1
svelte: ^5.42.2 => 5.53.5
vite: ^6.4.1 => 6.4.2
Severity
blocking an upgrade
Additional Information
No response
Reactions are currently unavailable