Skip to content

Add tests for inferring contextual generic mapped types #52709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Feb 9, 2023

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 @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)

@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Feb 9, 2023
// @strict: true
// @noEmit: true

type LowInfer<T> = T & {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since those tests are using LowInfer - cc @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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can play around with those test cases in the TS 4.7 playground where they error.

@sandersn sandersn merged commit d5ccec3 into microsoft:main Mar 3, 2023
@Andarist Andarist deleted the test/contextual-generic-mapped-type branch March 7, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants