URL and URLSearchParams globals lack native TypeScript declarations without DOM libs
Issue Description
NativeScript runtime support for URL and URLSearchParams is tracked in #10297, which lists both as available since 8.7. In a NativeScript TypeScript project that omits the browser DOM library, however, TypeScript cannot use these runtime-supported globals through @nativescript/types.
This is a build-time typing report; it does not claim that the runtime constructor is missing.
It would help if @nativescript/types exposed the supported URL and URLSearchParams globals without requiring the full DOM library, or documented the supported typing setup for this case. Enabling all DOM types also declares browser globals such as document that are unavailable in NativeScript apps, so it can hide accidental use of unsupported APIs.
Reproduction
With @nativescript/core 9.1.2, @nativescript/types 9.0.0, TypeScript 5.9.3, and this native compiler configuration:
{
"compilerOptions": {
"lib": ["ESNext"],
"types": ["@nativescript/types", "vite/client"]
}
}Compile this code:
const url = new URL('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
console.log(url.hostname, url.pathname, url.searchParams.get('v'));TypeScript reports:
TS2693: 'URL' only refers to a type, but is being used as a value here.
TS2339: Property 'hostname' does not exist on type 'URL'.
TS2339: Property 'pathname' does not exist on type 'URL'.
TS2339: Property 'searchParams' does not exist on type 'URL'.Relevant log output (if applicable)
Build-time TypeScript diagnostics shown above. No runtime exception is being reported.
Environment
@nativescript/core: 9.1.2@nativescript/types: 9.0.0- TypeScript: 5.9.3
- Native
tsconfig:lib: ["ESNext"],types: ["@nativescript/types", "vite/client"]
Please accept these terms
- I have searched the existing issues as well as StackOverflow and this has not been posted before. Existing #10297 tracks runtime API support, while this report concerns native TypeScript declarations without DOM globals.
- This is a bug report
- I agree to follow this project's Code of Conduct
Source: NativeScript/NativeScript