[PR #323] [MERGED] feat: add global.d.ts for window.__VINEXT_* and globalThis.__VINEXT_* globals #479

Closed
opened 2026-05-06 13:08:18 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/323
Author: @james-elicx
Created: 3/7/2026
Status: Merged
Merged: 3/7/2026
Merged by: @james-elicx

Base: mainHead: feat/global-d-ts-vinext-globals


📝 Commits (2)

  • edb8065 feat: add global.d.ts for window._VINEXT* and globalThis._VINEXT* globals
  • 95ec895 feat: declare window.NEXT_DATA in global.d.ts, remove remaining (window as any) casts

📊 Changes

8 files changed (+338 additions, -43 deletions)

View changed files

📝 packages/vinext/src/client/entry.ts (+3 -3)
packages/vinext/src/global.d.ts (+301 -0)
📝 packages/vinext/src/server/dev-server.ts (+3 -3)
📝 packages/vinext/src/server/prod-server.ts (+1 -1)
📝 packages/vinext/src/shims/form.tsx (+2 -3)
📝 packages/vinext/src/shims/link.tsx (+6 -8)
📝 packages/vinext/src/shims/navigation.ts (+11 -13)
📝 packages/vinext/src/shims/router.ts (+11 -12)

📄 Description

Summary

  • Adds packages/vinext/src/global.d.ts declaring all 23 __VINEXT_* runtime globals used across the codebase
  • Covers Window interface augmentation (browser-side), var declarations for self/globalThis globals (RSC chunks, server-side manifests, locale state), and ProcessEnv augmentation for Vite define-replaced constants
  • Removes all (window as any).__VINEXT_* and (globalThis as any).__VINEXT_* escape hatches from client/entry.ts, server/dev-server.ts, server/prod-server.ts, shims/form.tsx, shims/link.tsx, shims/navigation.ts, and shims/router.ts

Files Changed

File Change
packages/vinext/src/global.d.ts New — ambient declarations for all __VINEXT_* globals
packages/vinext/src/client/entry.ts Remove (window as any) cast
packages/vinext/src/server/dev-server.ts Remove (globalThis as any) casts
packages/vinext/src/server/prod-server.ts Remove (globalThis as any) cast
packages/vinext/src/shims/form.tsx Remove (window as any) cast
packages/vinext/src/shims/link.tsx Remove (window as any) and (globalThis as any) casts
packages/vinext/src/shims/navigation.ts Remove (window as any) casts
packages/vinext/src/shims/router.ts Remove (window as any) casts

Testing

  • pnpm run typecheck — passes with zero errors
  • pnpm run lint — 0 warnings, 0 errors
  • pnpm test tests/shims.test.ts tests/link.test.ts — 590/590 tests pass

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/323 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 3/7/2026 **Status:** ✅ Merged **Merged:** 3/7/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `feat/global-d-ts-vinext-globals` --- ### 📝 Commits (2) - [`edb8065`](https://github.com/cloudflare/vinext/commit/edb806587cf719351c15146bb0b70200ff00e990) feat: add global.d.ts for window.__VINEXT_* and globalThis.__VINEXT_* globals - [`95ec895`](https://github.com/cloudflare/vinext/commit/95ec89527e6c24c6b5196f7a12051038e6f409a9) feat: declare window.__NEXT_DATA__ in global.d.ts, remove remaining (window as any) casts ### 📊 Changes **8 files changed** (+338 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/client/entry.ts` (+3 -3) ➕ `packages/vinext/src/global.d.ts` (+301 -0) 📝 `packages/vinext/src/server/dev-server.ts` (+3 -3) 📝 `packages/vinext/src/server/prod-server.ts` (+1 -1) 📝 `packages/vinext/src/shims/form.tsx` (+2 -3) 📝 `packages/vinext/src/shims/link.tsx` (+6 -8) 📝 `packages/vinext/src/shims/navigation.ts` (+11 -13) 📝 `packages/vinext/src/shims/router.ts` (+11 -12) </details> ### 📄 Description ## Summary - Adds `packages/vinext/src/global.d.ts` declaring all 23 `__VINEXT_*` runtime globals used across the codebase - Covers `Window` interface augmentation (browser-side), `var` declarations for `self`/`globalThis` globals (RSC chunks, server-side manifests, locale state), and `ProcessEnv` augmentation for Vite `define`-replaced constants - Removes all `(window as any).__VINEXT_*` and `(globalThis as any).__VINEXT_*` escape hatches from `client/entry.ts`, `server/dev-server.ts`, `server/prod-server.ts`, `shims/form.tsx`, `shims/link.tsx`, `shims/navigation.ts`, and `shims/router.ts` ## Files Changed | File | Change | |------|--------| | `packages/vinext/src/global.d.ts` | **New** — ambient declarations for all `__VINEXT_*` globals | | `packages/vinext/src/client/entry.ts` | Remove `(window as any)` cast | | `packages/vinext/src/server/dev-server.ts` | Remove `(globalThis as any)` casts | | `packages/vinext/src/server/prod-server.ts` | Remove `(globalThis as any)` cast | | `packages/vinext/src/shims/form.tsx` | Remove `(window as any)` cast | | `packages/vinext/src/shims/link.tsx` | Remove `(window as any)` and `(globalThis as any)` casts | | `packages/vinext/src/shims/navigation.ts` | Remove `(window as any)` casts | | `packages/vinext/src/shims/router.ts` | Remove `(window as any)` casts | ## Testing - `pnpm run typecheck` — passes with zero errors - `pnpm run lint` — 0 warnings, 0 errors - `pnpm test tests/shims.test.ts tests/link.test.ts` — 590/590 tests pass --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:18 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#479
No description provided.