Uh oh!
There was an error while loading. Please reload this page.
Expand constraint suggestion related span and add quick fix - #49481
Conversation
Ryan Cavanaugh (RyanCavanaugh)
commented
Jun 10, 2022
TypeScript Bot (@typescript-bot) pack this |
Heya Ryan Cavanaugh (@RyanCavanaugh), I've started to run the tarball bundle task on this PR at 00ef5ae. You can monitor the build here. |
Hey Ryan Cavanaugh (@RyanCavanaugh), I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build and an npm module you can use via |
Ryan Cavanaugh (RyanCavanaugh)
commented
Jun 10, 2022
Most of the breaks I saw looked like this, which currently isn't quickfixable. Can we expand it? interfaceFn<Textendsstring>{}functionm<T>(x: Fn<T>){} |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Wesley Wigham (weswigham)
commented
Jun 10, 2022
Sure, should be easy - just another error code in the quickfix hopefully, since it uses a custom head message on the assignability error. |
Wesley Wigham (weswigham)
commented
Jun 10, 2022
Ryan Cavanaugh (@RyanCavanaugh) done. There are a lot of custom head messages for relation errors, and thus, many error codes we could conceivably add to this quickfix. I don't claim the current list to be exhaustive, just the ones I read in the core |
Ryan Cavanaugh (RyanCavanaugh)
commented
Jun 10, 2022
TypeScript Bot (@typescript-bot) pack this |
Heya Ryan Cavanaugh (@RyanCavanaugh), I've started to run the tarball bundle task on this PR at d70dc0a. You can monitor the build here. |
Hey Ryan Cavanaugh (@RyanCavanaugh), I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build and an npm module you can use via |
Andrew Branch (andrewbranch)
commented
Jun 13, 2022
(This isn’t the first time it would have been nice to be able to register a codefix against a related error instead of the head message.) |
Andrew Branch (andrewbranch)
left a comment
There was a problem hiding this comment.
We should keep an eye out for how often the related diagnostic / quick fix is the correct fix in real world code since it seems to be showing up a lot more often.
Wesley Wigham (weswigham)
commented
Jun 15, 2022
It's any time you assign an unconstrained type parameter to something, so potentially pretty often. Conversely, it's probably got a pretty high success rate, I think. The other way you'd have to take the fix is changing the target type's position to |
Wesley Wigham (weswigham)
commented
Jun 15, 2022
Notably, that failure mode does imply another, narrower, potentially useful quickfix - if a constrained type parameter fails being related to some target type, suggesting the target type be intersected into the constraint of the source type parameter is potentially a good fix. Unfortunately, a large corpus of code with errors isn't exactly something we have to know how useful such a fix would be. |
This expands the originally very narrow elaboration to be reported any time an unconstrained type parameter is related to something, and adds a quickfix to apply the change.