Skip to content
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

Cascade out type parameters for TypeScript 4.8 #9919

Conversation

DanielRosenwasser
Copy link

Hi there! 👋

TypeScript recently added some stricter checking around unconstrained generics being incompatible with emptyish object types. The changes are only in nightly versions of TypeScript right now, but we've been exploring how open-source projects have been impacted. These are the changes necessary for apollo-client to build cleanly in TypeScript 4.8.

@apollo-cla
Copy link

@DanielRosenwasser: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@@ -226,7 +227,7 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
}
}

public diff<TData, TVariables = any>(
public diff<TData, TVariables extends OperationVariables = any>(
Copy link
Author

Choose a reason for hiding this comment

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

This could possibly be changed to

Suggested change
public diff<TData, TVariables extends OperationVariables = any>(
public diff<TData, TVariables extends OperationVariables = OperationVariables>(

TGraphQLVariables = {},
TChildProps = DataProps<TData, TGraphQLVariables>
TGraphQLVariables extends {} = {},
TChildProps extends { [x: string]: any; } = DataProps<TData, TGraphQLVariables>
Copy link
Author

Choose a reason for hiding this comment

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

A possible alternative:

Suggested change
TChildProps extends { [x: string]: any; } = DataProps<TData, TGraphQLVariables>
TChildProps extends Partial<DataProps<TData, TGraphQLVariables>> = DataProps<TData, TGraphQLVariables>

or possibly, but suspiciously

Suggested change
TChildProps extends { [x: string]: any; } = DataProps<TData, TGraphQLVariables>
TChildProps extends {} = DataProps<TData, TGraphQLVariables>

@jpvajda
Copy link
Contributor

jpvajda commented Aug 1, 2022

@DanielRosenwasser Thank you for making us aware of this change!

@jpvajda
Copy link
Contributor

jpvajda commented Aug 2, 2022

@hwillson hwillson added this to the Release 3.8 milestone Aug 2, 2022
@jpvajda
Copy link
Contributor

jpvajda commented Aug 2, 2022

The team discussed and we will target this for our upcoming 3.8 release as the GA for 4.8 looks to be aug 23 according to the iteration plan.

@jpvajda jpvajda changed the base branch from main to renovate/typescript-4.x September 20, 2022 18:00
@jpvajda jpvajda merged commit 634dc7f into apollographql:renovate/typescript-4.x Sep 20, 2022
@jpvajda
Copy link
Contributor

jpvajda commented Sep 20, 2022

these changes are squashed into #10041 to see if this change will help with the TS 4.8 upgrade.

alessbell pushed a commit that referenced this pull request Jan 23, 2023
* Cascade out type parameters for TypeScript 4.8

* Add apparent fix for `graphql.tsx` by making TChildProps expect a partial type.
@alessbell alessbell mentioned this pull request Jan 23, 2023
3 tasks
alessbell pushed a commit that referenced this pull request Jan 25, 2023
* Cascade out type parameters for TypeScript 4.8

* Add apparent fix for `graphql.tsx` by making TChildProps expect a partial type.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants