TypeScript-DOM-lib-generator
TypeScript-DOM-lib-generator copied to clipboard
ResponseConstructor
I would like to globally augment the ResponseConstructor (e.g. add the missing json(data, init) static method, safely add my own using unique symbols, etc.).
However I do not see how to do that as var Response isn't defined with a named type.
https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/48c4695b3f61534f1a6de8a598b35b81000491e3/baselines/dom.generated.d.ts#L12436-L12441
I suggest extracting the type to an interface, e.g. named ResponseConstructor to enable global augmentation of these types.
There are likely other types/constructors that could also be given named types too (e.g. AbortController, etc.).
The way to extend static part is requested multiple times, I still think the right way to do this is to convert them to class declarations. (Because, well, they are classes.)
This specific case will be solved once Gecko or WebKit adds the support in https://bugzilla.mozilla.org/show_bug.cgi?id=1758943 or https://github.com/WebKit/WebKit/pull/10593.
The way to extend static part is requested multiple times, I still think the right way to do this is to convert them to class declarations. (Because, well, they are classes.)
Until https://github.com/microsoft/TypeScript/issues/36813 is supported, declaring them as classes won't work for augmenting Response with properties keyed using unique symbols.
This specific case will be solved once Gecko or WebKit adds the support in https://bugzilla.mozilla.org/show_bug.cgi?id=1758943 or WebKit/WebKit#10593.
That's true but I want to define my own too using unique symbols. e.g. Response[html](), Response[notFound](), etc.