Skip to content

Commit

Permalink
work around TS 4.8-specific infer X extends Y (#11337)
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Nov 2, 2023
1 parent 0de3b29 commit bb1da83
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .api-reports/api-report-cache.md
Expand Up @@ -885,7 +885,7 @@ export interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
export type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-core.md
Expand Up @@ -2015,7 +2015,7 @@ export interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
export type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react.md
Expand Up @@ -1859,7 +1859,7 @@ interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_components.md
Expand Up @@ -1594,7 +1594,7 @@ interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_context.md
Expand Up @@ -1529,7 +1529,7 @@ interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_hoc.md
Expand Up @@ -1550,7 +1550,7 @@ interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_hooks.md
Expand Up @@ -1752,7 +1752,7 @@ interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_ssr.md
Expand Up @@ -1516,7 +1516,7 @@ interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-testing.md
Expand Up @@ -1548,7 +1548,7 @@ interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-testing_core.md
Expand Up @@ -1504,7 +1504,7 @@ interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-utilities.md
Expand Up @@ -2298,7 +2298,7 @@ export interface StoreObject {
}

// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
export type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report.md
Expand Up @@ -2462,7 +2462,7 @@ export interface StoreObject {
// Warning: (ae-forgotten-export) The symbol "AsStoreObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<infer Item extends Record<string, any>> ? ReadonlyArray<AsStoreObject<Item> | Reference> : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? Item extends Record<string, any> ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;

// @public (undocumented)
export type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
Expand Down
6 changes: 6 additions & 0 deletions .changeset/stupid-chairs-wait.md
@@ -0,0 +1,6 @@
---
"@apollo/client": patch
---

#11206 used the TypeScript syntax `infer X extends Y` that was introduced in TS 4.8.
This caused some problems for some users, so we are rolling back to a more backwars-compatible (albeit slightly less performant) type.
8 changes: 6 additions & 2 deletions src/cache/core/types/common.ts
Expand Up @@ -106,9 +106,13 @@ export type Modifier<T> = (
) => T | DeleteModifier | InvalidateModifier;

type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<
infer Item extends Record<string, any>
Record<string, any>
>
? ReadonlyArray<AsStoreObject<Item> | Reference>
? StoreVal extends Array<infer Item>
? Item extends Record<string, any>
? ReadonlyArray<AsStoreObject<Item> | Reference>
: never
: never
: StoreVal extends Record<string, any>
? AsStoreObject<StoreVal> | Reference
: StoreVal;
Expand Down

0 comments on commit bb1da83

Please sign in to comment.