| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Both runtimes have provided WHATWG URL and URLSearchParams natively since 8.7 (ada-url based), but nothing declared them for projects compiled without the DOM lib, so `new URL(...)` failed typecheck. Adds globals.d.ts to @nativescript/types declaring the runtime surface: URL with searchParams but no toJSON/parse/webkitURL, URLSearchParams with live entries/keys/values iterators and the newer delete/has value parameters. Shapes mirror lib.dom.d.ts so the interfaces merge cleanly when a project also includes the DOM lib; the var redeclaration is resolved by skipLibCheck, same tradeoff as @types/node.
|
View your CI Pipeline Execution ↗ for commit 9b21163
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at 2026-10-05 18:20:26 UTC |
Sorry, something went wrong.
npm i https://pkg.pr.new/@nativescript/core@11482 npm i https://pkg.pr.new/@nativescript/vite@11482 npm i https://pkg.pr.new/@nativescript/webpack@11482 commit: 9b21163 |
Sorry, something went wrong.
|
Hello! Thanks for the contribution. While this works, can you make it similar to what node does instead, so it's impossible for us to conflict with the other global definitions of URL https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/web-globals/url.d.ts |
Sorry, something went wrong.
Restructures the URL/URLSearchParams declarations after maintainer
feedback to follow the @types/node web-globals pattern: shapes live in
a module-scoped `url` namespace and are bound inside `declare global`.
The global interfaces extend the module types (merging with lib.dom's)
and the `var` declarations use `typeof globalThis extends
{ onmessage: any; URL: infer T } ? T : ...` so they adopt the type of
any existing global definition instead of conflicting with it — no more
TS2403 against lib.dom even without skipLibCheck.
| Back | FazBrowse Home | New Git URL |
PR Checklist
What is the current behavior?
Both runtimes have exposed URL and URLSearchParams as globals since 8.7 (ada-url based; URLImpl/URLSearchParamsImpl + blob-url.js in ns-v8ios-runtime and android-runtime), but nothing declares them for projects compiled without the DOM lib. With "lib": ["ESNext"] and "types": ["@nativescript/types"], new URL(...) fails typecheck even though it works at runtime.
What is the new behavior?
Adds packages/types/globals.d.ts, referenced from the package's index.d.ts, declaring the surface the runtimes actually implement:
The interface members mirror lib.dom.d.ts exactly (including readonly modifiers), so when a project also includes the DOM lib the interfaces merge without conflict and the DOM var declaration — which additionally declares toJSON/parse — wins. As with any constructor global (@types/node does the same), a var redeclaration vs lib.dom.d.ts is reported as TS2403 when skipLibCheck is disabled; skipLibCheck is on in this repo and the standard app configs.
Placement note: these are runtime-provided globals, unlike the core-polyfilled globals (fetch, setTimeout, ...) declared in packages/core/global-types.d.ts, so they live in @nativescript/types — the typings entry point named in the issue — rather than in core.
No committed test: the types packages have no test target/typings-test framework. Verified manually with tsc 5.9.3:
Fixes #11456.