Attempt to add interface for constuctors to add static properites #1379
+3,099
−2,052
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.
OK, this PR is a headache and a trip down the rabbit hole for me. It's technically a broken PR as I know one test fails, but I can't fix it without input on how.
Long story short, I'm working with a team to develop a types package for a framework (I guess that's the best way to put it, Foundry VTT for the interested), and in there they patch in a number of static and instance methods to built in objects (not ideal, but we have don't have control on this).
This was fine for most things to add static methods to things like
Array
andNumber
which hadArrayConstructor
andNumberConstructor
as ways to extend the constructor's types. Totally fine, up to this point. Then they added a static method forURL
andURLConstructor
does not exist. My temp fix locally was to manually redefine theURL
variable instance since it's a type rather than an interface and slap a@ts-expect-error
comment on it for now, but I figured this is something that could be fixed up stream and give everything I can a constructor interface.Good news, I did that, works just fine for almost everything. Bad news, broke a single test because of a snowflake. So much for a simple PR to make things better. My simple patch does generate for URL (and others) the same style of constructor interface for type merging, worked for all but
AudioWorkletProcessor
, as it already hasAudioWorkletProcessorConstructor
defined.Now the "offending" bit is defined here
TypeScript-DOM-lib-generator/inputfiles/overridingTypes.jsonc
Lines 406 to 410 in 804bc3b
AudioWorkletProcessorImpl
exists to deal with theprocess
method.I leave this here in a vague hope that my last 4 hours of head scratching, poking, and prodding to find out why
URLConstructor
did not exist while trying to add it in helps somewhat.