Uh oh!
There was an error while loading. Please reload this page.
Add tests for inferring contextual generic mapped types - #52709
Conversation
TypeScript Bot (typescript-bot)
commented
Feb 9, 2023
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
| // @strict: true | ||
| // @noEmit: true | ||
| type LowInfer<T> = T & {}; |
There was a problem hiding this comment.
Since those tests are using LowInfer - cc Ryan Cavanaugh (@RyanCavanaugh) who was mentioning this as a somewhat viable and stable pattern in some of the issues
| interface AssignAction<TContext> { | ||
| type: "xstate.assign"; | ||
| exec: (arg: TContext, meta: Meta<TContext>) => void; |
There was a problem hiding this comment.
The only difference between those 2 tests is that this one is using a property with a function value here and the other one is using a callable signature. Both cases are somewhat important for us in XState.
| @@ -0,0 +1,41 @@ | |||
| // @strict: true | |||
There was a problem hiding this comment.
You can play around with those test cases in the TS 4.7 playground where they error.
This PR only introduces some tests. We started relying on this in XState and it turned out that this doesn't work pre-4.8.
I tracked down the PR that enabled this use case: #49696 (cc Anders Hejlsberg (@ahejlsberg) ). It wasn't fixing any case like that (no similar tests introduced there) so I figured out that it's best for us to provide tests for this here - to ensure that this won't accidentally regress (as long as you believe that this should continue to work, of course)