Repository navigation
fix(types): declare runtime URL and URLSearchParams globals - #11482
Merged
Merged
Conversation
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 |
commit: |
Contributor
|
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 |
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.
NathanWalker
approved these changes
Oct 6, 2026
aleclarson
added a commit
to octane-xplat/octane-xplat
that referenced
this pull request
Oct 8, 2026
The ambient @nativescript/types URL declaration (no toJSON, matching the
native runtime) owns the global URL binding in app typecheck programs, so
new URL(...) in these node-side configs no longer satisfies fs PathLike,
which wants import("url").URL. Import the node class explicitly.
---
chore(deps): bump @nativescript/types to 9.1.4 and @octanejs/tiptap to 0.0.52
@nativescript/types 9.1.4 ships the URL/URLSearchParams ambient
declarations (NativeScript/NativeScript#11482), so the pnpm patch is
dropped entirely — manifest entry, patch file, and patchedDependencies.
@octanejs/tiptap 0.0.52 lands the './Context' disambiguation
(octanejs/octane#1502), so the patch shrinks to the remaining
process.env guard in useEditor.ts (closed unmerged upstream).
types-ios 9.1.3 tightens nullability: NSNotification.userInfo and
UIApplication.keyWindow are now nullable — optional-chain the
interruption observer reads in audio.ios and cast the keyWindow
fallback in auth-session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
What is the current behavior?
Both runtimes have exposed
URLandURLSearchParamsas globals since 8.7 (ada-url based;URLImpl/URLSearchParamsImpl+blob-url.jsinns-v8ios-runtimeandandroid-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'sindex.d.ts, declaring the surface the runtimes actually implement:URL:hash/host/hostname/href/password/pathname/port/protocol/search/username(read-write),originandsearchParams(read-only),toString(); staticscanParse,createObjectURL,revokeObjectURL. Deliberately omitted because the runtimes don't implement them:toJSON(), staticparse(),webkitURL. The constructor's first parameter is typedstringbecause the runtime throws a TypeError for anything else (new URL(urlInstance)works in browsers but not on-device).URLSearchParams:size,append,delete(name, value?),get,getAll,has(name, value?),set,sort,toString,forEach, liveentries/keys/valuesiterators andSymbol.iterator. The constructor accepts a string, record,string[][], anotherURLSearchParams, or any iterable of pairs.The interface members mirror
lib.dom.d.tsexactly (includingreadonlymodifiers), so when a project also includes the DOM lib the interfaces merge without conflict and the DOMvardeclaration — which additionally declarestoJSON/parse— wins. As with any constructor global (@types/nodedoes the same), avarredeclaration vslib.dom.d.tsis reported as TS2403 whenskipLibCheckis disabled;skipLibCheckis on in this repo and the standard app configs.Placement note: these are runtime-provided globals, unlike the core-polyfilled globals (
fetch,setTimeout, ...) declared inpackages/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
tsc5.9.3:lib: ["ESNext"],types: ["@nativescript/types"](issue's repro config, simulated published package layout):new URL(...),hostname,pathname,searchParams.get(),canParse,URLSearchParamsiteration all typecheck;toJSON/URL.parse/new URL(urlObj)correctly error.skipLibCheck: clean.lib: ["ESNext","DOM","DOM.Iterable"]+skipLibCheck: clean; DOM-only members resolve via the merged DOM declaration.Fixes #11456.