-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix link/core/types to be compatible with graphql typings while TypeScript exactOptionalPropertyTypes mode is enabled #10497
Conversation
🦋 Changeset detectedLatest commit: 4d552b2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…cript strict mode is on When importing `@apollo/client` in a project with TS 4.9, graphql 16.6 and `strict: true`, we see the following compilation error: ``` ./node_modules/@apollo/client/link/core/types.d.ts(44,18): error TS2430: Interface 'SingleExecutionResult<TData, TContext, TExtensions>' incorrectly extends interface 'ExecutionResult<TData, TExtensions>'. Types of property 'data' are incompatible. Type 'Data<TData>' is not assignable to type 'TData | null'. Type 'undefined' is not assignable to type 'TData | null'. ``` Because `Data<TData>` expands to: ```ts data?: TData | undefined | null ``` Which is subtly different from: ```ts data?: TData | null ``` This fixes the type to be compatible.
Hi @nevir 👋 I'd like to understand the problem a bit better; I've tried to reproduce this and wasn't able to in https://github.com/apollographql/router-defer-e2e-tests. If you clone that repo, cd into |
Looks like Removing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅
When importing
@apollo/client
in a project with TS 4.9, graphql 16.6 andstrict: true
andexactOptionalPropertyTypes: true
, we see the following compilation error:Because
Data<TData>
expands to:Which is subtly different from:
E.g. the GraphQL types are declaring that
data
can be not present in the object, but it should not be explicitly{ data: undefined }
.For extra context, check the TypeScript docs on the
exactOptionalPropertyTypes
flagThis fixes the type to be compatible.