Skip to content

Commit

Permalink
Fix link/core/types when TypeScript exactOptionalPropertyTypes mode i…
Browse files Browse the repository at this point in the history
…s enabled (#10497)

---------

Co-authored-by: alessia <alessia@apollographql.com>
  • Loading branch information
nevir and alessbell authored Feb 10, 2023
1 parent 59652a7 commit 8a883d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-berries-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

Update `SingleExecutionResult` and `IncrementalPayload`'s `data` types such that they no longer include `undefined`, which was not a valid runtime value, to fix errors when TypeScript's `exactOptionalPropertyTypes` is enabled.
8 changes: 3 additions & 5 deletions src/link/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ export { DocumentNode };
import { Observable } from "../../utilities";

export type Path = ReadonlyArray<string | number>;
type Data<T> = T | null | undefined;


interface ExecutionPatchResultBase {
hasNext?: boolean;
Expand All @@ -17,7 +15,7 @@ export interface ExecutionPatchInitialResult<
TExtensions = Record<string, any>
> extends ExecutionPatchResultBase {
// if data is present, incremental is not
data: Data<TData>;
data: TData | null | undefined;
incremental?: never;
errors?: ReadonlyArray<GraphQLError>;
extensions?: TExtensions;
Expand All @@ -29,7 +27,7 @@ export interface IncrementalPayload<
> {
// data and path must both be present
// https://github.com/graphql/graphql-spec/pull/742/files#diff-98d0cd153b72b63c417ad4238e8cc0d3385691ccbde7f7674bc0d2a718b896ecR288-R293
data: Data<TData>;
data: TData | null;
label?: string;
path: Path;
errors?: ReadonlyArray<GraphQLError>;
Expand Down Expand Up @@ -79,7 +77,7 @@ export interface SingleExecutionResult<
TContext = DefaultContext,
TExtensions = Record<string, any>
> extends ExecutionResult<TData, TExtensions> {
data?: Data<TData>;
data?: TData | null;
context?: TContext;
}

Expand Down

0 comments on commit 8a883d8

Please sign in to comment.