[@types/node] new URL(input) should accept URLs
#68454
-
SummaryThere's a minor type issue where DefinitelyTyped/types/node/url.d.ts Line 415 in eaaf5e4 Should be: constructor(input: string | URL, base?: string | URL);Technically it should support other stringifiers, but may not be necessary for this fix. Documentation
Examples/Use CasesThe follow example is valid in Node.js, but is not with const input = new URL('https://example.com');
const output = new URL(input);This can be helpful in real-world use cases where an API may want to accept a URL as a export interface Config {
/**
* An endpoint to use.
*
* @example
* 'https://localhost:8080/'
*/
endpoint: string | URL;
}
function resolveURL (config: Config): URL {
// currently a type error today
return new URL(config.endpoint);
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Thanks for the discussion about "node", some useful links for everyone: Pinging the DT module owners: @microsoft, @jkomyno, @alvis, @r3nya, @btoueg, @smac89, @Touffy, @DeividasBakanas, @eyqs, @Hannes-Magnusson-CK, @hoo29, @kjin, @ajafff, @islishude, @mwiktorczyk, @mohsen1, @n-e, @galkin, @parambirs, @eps1lon, @ThomasdenH, @WilcoBakker, @wwwy3y3, @samuela, @kuehlein, @bhongy, @chyzwar, @trivikr, @yoursunny, @qwelias, @ExE-Boss, @peterblazejewicz, @addaleax, @victorperin, @ZYSzys, @nodejs, @LinusU, @wafuwafu13, @mcollina, @Semigradsky. |
Beta Was this translation helpful? Give feedback.
-
|
Fixed in PR #68456 |
Beta Was this translation helpful? Give feedback.
Fixed in PR #68456