Uh oh!
There was an error while loading. Please reload this page.
Reinterpret a type parameter constrained to any as an upper bound constraint - #29571
Conversation
Ryan Cavanaugh (RyanCavanaugh)
commented
Jan 25, 2019
TypeScript Bot (@typescript-bot) test this |
Heya Ryan Cavanaugh (@RyanCavanaugh), I've started to run the extended test suite on this PR at 570c756. You can monitor the build here. It should now contribute to this PR's status checks. |
Ryan Cavanaugh (RyanCavanaugh)
commented
Jan 25, 2019
Also run on DT |
Wesley Wigham (weswigham)
commented
Mar 8, 2019
Heya Wesley Wigham (@weswigham), I've started to run the Definitely Typed test suite on this PR at 7c13b70. You can monitor the build here. It should now contribute to this PR's status checks. |
Wesley Wigham (weswigham)
commented
Mar 8, 2019
Updated the test that needed changing to a constraint that actually typechecks, and looked at DT - failures are in So this seems pretty good - if anything, like the tests I just changed, it's going to identify places we were silently allowing unsafe operations. |
Ryan Cavanaugh (RyanCavanaugh)
commented
Mar 13, 2019
Wesley Wigham (@weswigham) let's merge for 3.5 |
Wesley Wigham (@weswigham) this sounds like it's ready to go, right? |
Wesley Wigham (weswigham)
commented
Feb 13, 2020
Probably. The change itself is small, so barring merge conflicts, should still be OK. |
After a merge from master: toString is now available on type parameters that extend any. That's the only difference I can see. |
Let's wait until Ryan Cavanaugh (@RyanCavanaugh) is back to merge this. |
Nathan Shively-Sanders (sandersn)
commented
Mar 3, 2020
I talked to Ryan Cavanaugh (@RyanCavanaugh) about this just now, so I'm going to merge it. |
Nathan Shively-Sanders (sandersn)
commented
Mar 4, 2020
Wesley Wigham (@weswigham) this causes a failure in DT on wordpress__block-editor-tests.tsx. Can you try to fix it? It looks like the offending signature is this: declarefunctionwithColorContext<ProvidedPropsextendsPartial<withColorContext.Props>,OwnPropsextendsany,TextendsComponentType<ProvidedProps&OwnProps>>(component: T):
TextendsComponentType<infer U> ? ComponentType<Omit<U,'colors'|'disableCustomColors'|'hasColorsToChoose'>&Omit<ProvidedProps,'hasColorsToChoose'>> :
never;Previously the second type argument was inferred If there's a mechanical fix to update existing code, it'd worthwhile to have that in the release notes for 3.9. |
Wesley Wigham (weswigham)
commented
Mar 4, 2020
Write an eg, typeGetClass<Textendsany>=T["class"];// could betypeGetClass<T>=Extract<T,{class: any}>["class"];obviously, you can replace
What's broken about it? the signature itself has nothing wrong as far as I can tell, so you're talking about a specific usage, right? |
If the answer is "we now infer |
Nathan Shively-Sanders (sandersn)
commented
Mar 6, 2020
Yes, line 142 of the tests. Probably |
Fixes#29509
Note, that we have a test that asserts that a type parameter explicitly extending
anybehaves likeanywhen accessing its members (which IMO is strange). This would be a break to that behavior.