This is a follow-up issue of #25342 and #19799.
In #25269 the URL and URLSearchParams classes have been added as globals because since Node.js 10.0 they are exposed as globals.
Because lib.dom.d.ts also exposes them as globals, projects which referenced both, node and lib.dom, got "Duplicate identifier 'URL'" errors (see #25342). Therefore the global URL and URLSearchParams has been removed again.
This fix (actually a workaround for a missing declaration merging feature of TypeScript) now has the drawback that we cannot use the global URL class in Node.js-code (instead we need to import it from the url module). This is especially bad for universal modules which are supposed to work in the browser + node by just using the global URL (which works since Node.js 10).
So I want to discuss solutions for this atm. unsupported scenario here. (Without having local declarations in consuming projects.)
One solution would be to support this scenario in TypeScript (allow - exactly same? - global class definitions in multiple declaration files). @weswigham Would this be possible?
A more straight-foward solution would be to create a new DT package (e.g. node-global-url or maybe better whatwg-global-url) which can be installed additionally and selected by using e.g. "types": ["node", "node-global-url"] in a tsconfig.json for projects which face the mentioned scenario above.
Any other ideas?
This is a follow-up issue of #25342 and #19799.
In #25269 the
URLandURLSearchParamsclasses have been added as globals because since Node.js 10.0 they are exposed as globals.Because
lib.dom.d.tsalso exposes them as globals, projects which referenced both,nodeandlib.dom, got "Duplicate identifier 'URL'" errors (see #25342). Therefore the globalURLandURLSearchParamshas been removed again.This fix (actually a workaround for a missing declaration merging feature of TypeScript) now has the drawback that we cannot use the global
URLclass in Node.js-code (instead we need to import it from theurlmodule). This is especially bad for universal modules which are supposed to work in the browser + node by just using the globalURL(which works since Node.js 10).So I want to discuss solutions for this atm. unsupported scenario here. (Without having local declarations in consuming projects.)
One solution would be to support this scenario in TypeScript (allow - exactly same? - global class definitions in multiple declaration files). @weswigham Would this be possible?
A more straight-foward solution would be to create a new DT package (e.g.
node-global-urlor maybe betterwhatwg-global-url) which can be installed additionally and selected by using e.g."types": ["node", "node-global-url"]in atsconfig.jsonfor projects which face the mentioned scenario above.Any other ideas?