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

Enable strict mode in tsconfig and fix type errors #11200

Merged
merged 33 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
aca904f
Enable strict mode in tsconfig.json
jerelmiller Sep 7, 2023
0da3d3d
Fix type issues in utilities/graphql/transform
jerelmiller Sep 7, 2023
78ccf61
Use spread to push incoming objects in offsetLimitPagination
jerelmiller Sep 7, 2023
69d528a
Fix type issues in writeToStore test
jerelmiller Sep 7, 2023
e503cbb
Fix type issues in Concast
jerelmiller Sep 7, 2023
0fe49a0
Remove unused filterInPlace utility
jerelmiller Sep 7, 2023
e34d084
Add this type to itAsync
jerelmiller Sep 7, 2023
962bd47
Add ! annotation to mockLink
jerelmiller Sep 7, 2023
36129f8
Fix assignment from unknown in error link
jerelmiller Sep 7, 2023
cea054e
Fix type issue in readFromStore
jerelmiller Sep 7, 2023
bed3439
Fix type issues in useQuery
jerelmiller Sep 7, 2023
b568689
some progress
phryneas Sep 8, 2023
6498326
more type fixes
phryneas Sep 13, 2023
b8c6eb6
change `addExportedVariables` signature
phryneas Sep 13, 2023
c3a761d
better typing
phryneas Sep 13, 2023
9eb5e3e
undo deprecation
phryneas Sep 13, 2023
0966cc9
Merge branch 'main' into enable-strict-mode
phryneas Sep 13, 2023
a101977
test types
phryneas Sep 13, 2023
55a6351
add api extractor
phryneas Sep 14, 2023
f909921
add api reports
phryneas Sep 14, 2023
e1e2fbb
add workflow
phryneas Sep 14, 2023
0426c84
formatting
phryneas Sep 14, 2023
be151b0
package lock
phryneas Sep 14, 2023
c83b042
remove `ensureResult` for this PR, add `TODO` type
phryneas Sep 14, 2023
4aa485b
Merge branch 'pr/api-extractor' into enable-strict-mode
phryneas Sep 14, 2023
1e7c5c6
API updates for this PR
phryneas Sep 14, 2023
c080309
Merge remote-tracking branch 'origin/main' into enable-strict-mode
phryneas Nov 10, 2023
0b2cf25
size-limit
phryneas Nov 10, 2023
9303630
introduce IDE-only `tsconfig.json`
phryneas Nov 10, 2023
5e3fb70
formatting
phryneas Nov 10, 2023
04dcc0d
fix path
phryneas Nov 10, 2023
2cb5c83
Merge pull request #11359 from apollographql/pr/enable-test-ts
jerelmiller Nov 10, 2023
94b07f9
Add changeset
jerelmiller Nov 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .api-reports/api-report-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace Cache_2 {
// (undocumented)
interface BatchOptions<TCache extends ApolloCache<any>, TUpdateResult = void> {
// (undocumented)
onWatchUpdated?: (this: TCache, watch: Cache_2.WatchOptions, diff: Cache_2.DiffResult<any>, lastDiff: Cache_2.DiffResult<any> | undefined) => any;
onWatchUpdated?: (this: TCache, watch: Cache_2.WatchOptions, diff: Cache_2.DiffResult<any>, lastDiff?: Cache_2.DiffResult<any> | undefined) => any;
// (undocumented)
optimistic?: string | boolean;
// (undocumented)
Expand Down Expand Up @@ -894,7 +894,7 @@ export type StoreValue = number | string | string[] | Reference | Reference[] |
class Stump extends Layer {
constructor(root: EntityStore.Root);
// (undocumented)
merge(): any;
merge(older: string | StoreObject, newer: string | StoreObject): void;
// (undocumented)
removeLayer(): this;
}
Expand Down
34 changes: 15 additions & 19 deletions .api-reports/api-report-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ namespace Cache_2 {
// (undocumented)
interface BatchOptions<TCache extends ApolloCache<any>, TUpdateResult = void> {
// (undocumented)
onWatchUpdated?: (this: TCache, watch: Cache_2.WatchOptions, diff: Cache_2.DiffResult<any>, lastDiff: Cache_2.DiffResult<any> | undefined) => any;
onWatchUpdated?: (this: TCache, watch: Cache_2.WatchOptions, diff: Cache_2.DiffResult<any>, lastDiff?: Cache_2.DiffResult<any> | undefined) => any;
// (undocumented)
optimistic?: string | boolean;
// (undocumented)
Expand Down Expand Up @@ -433,7 +433,7 @@ class Concast<T> extends Observable<T> {
// (undocumented)
cancel: (reason: any) => void;
// (undocumented)
readonly promise: Promise<T>;
readonly promise: Promise<T | undefined>;
// (undocumented)
removeObserver(observer: Observer<T>): void;
}
Expand Down Expand Up @@ -929,8 +929,6 @@ export class HttpLink extends ApolloLink {
constructor(options?: HttpOptions);
// (undocumented)
options: HttpOptions;
// (undocumented)
requester: RequestHandler;
}

// @public (undocumented)
Expand Down Expand Up @@ -1164,15 +1162,13 @@ class LocalState<TCacheShape> {
// Warning: (ae-forgotten-export) The symbol "LocalStateOptions" needs to be exported by the entry point index.d.ts
constructor({ cache, client, resolvers, fragmentMatcher, }: LocalStateOptions<TCacheShape>);
// (undocumented)
addExportedVariables(document: DocumentNode, variables?: OperationVariables, context?: {}): Promise<{
[x: string]: any;
}>;
addExportedVariables<TVars extends OperationVariables>(document: DocumentNode, variables?: TVars, context?: {}): Promise<TVars>;
// (undocumented)
addResolvers(resolvers: Resolvers | Resolvers[]): void;
// (undocumented)
clientQuery(document: DocumentNode): DocumentNode | null;
// (undocumented)
getFragmentMatcher(): FragmentMatcher;
getFragmentMatcher(): FragmentMatcher | undefined;
// (undocumented)
getResolvers(): Resolvers;
// (undocumented)
Expand Down Expand Up @@ -1553,7 +1549,7 @@ export type OptimisticStoreItem = {
};

// @public (undocumented)
type OptionsUnion<TData, TVariables extends OperationVariables, TContext> = WatchQueryOptions<TVariables, TData> | QueryOptions<TVariables, TData> | MutationOptions<TData, TVariables, TContext>;
type OptionsUnion<TData, TVariables extends OperationVariables, TContext> = WatchQueryOptions<TVariables, TData> | QueryOptions<TVariables, TData> | MutationOptions<TData, TVariables, TContext, any>;

// @public (undocumented)
export function parseAndCheckHttpResponse(operations: Operation | Operation[]): (response: Response) => Promise<any>;
Expand Down Expand Up @@ -1633,7 +1629,7 @@ class QueryInfo {
document: DocumentNode;
variables: Record<string, any> | undefined;
networkStatus?: NetworkStatus;
observableQuery?: ObservableQuery<any>;
observableQuery?: ObservableQuery<any, any>;
lastRequestId?: number;
}): this;
// (undocumented)
Expand All @@ -1655,7 +1651,7 @@ class QueryInfo {
// (undocumented)
notify(): void;
// (undocumented)
readonly observableQuery: ObservableQuery<any> | null;
readonly observableQuery: ObservableQuery<any, any> | null;
// (undocumented)
readonly queryId: string;
// (undocumented)
Expand All @@ -1665,7 +1661,7 @@ class QueryInfo {
// (undocumented)
setDiff(diff: Cache_2.DiffResult<any> | null): void;
// (undocumented)
setObservableQuery(oq: ObservableQuery<any> | null): void;
setObservableQuery(oq: ObservableQuery<any, any> | null): void;
// (undocumented)
stop(): void;
// (undocumented)
Expand Down Expand Up @@ -1939,7 +1935,7 @@ export interface Resolvers {
//
// @public (undocumented)
export function rewriteURIForGET(chosenURI: string, body: Body_2): {
parseError: any;
parseError: unknown;
newURI?: undefined;
} | {
newURI: string;
Expand Down Expand Up @@ -2022,7 +2018,7 @@ export type StoreValue = number | string | string[] | Reference | Reference[] |
class Stump extends Layer {
constructor(root: EntityStore.Root);
// (undocumented)
merge(): any;
merge(older: string | StoreObject, newer: string | StoreObject): void;
// (undocumented)
removeLayer(): this;
}
Expand Down Expand Up @@ -2186,11 +2182,11 @@ interface WriteContext extends ReadMergeModifyContext {
// src/cache/inmemory/policies.ts:167:3 - (ae-forgotten-export) The symbol "KeySpecifier" needs to be exported by the entry point index.d.ts
// src/cache/inmemory/policies.ts:167:3 - (ae-forgotten-export) The symbol "KeyArgsFunction" needs to be exported by the entry point index.d.ts
// src/cache/inmemory/types.ts:126:3 - (ae-forgotten-export) The symbol "KeyFieldsFunction" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:112:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:113:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:116:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:149:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:378:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:113:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:114:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:117:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:150:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:379:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:191:3 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/link/http/selectHttpOptionsAndBody.ts:128:32 - (ae-forgotten-export) The symbol "HttpQueryOptions" needs to be exported by the entry point index.d.ts

Expand Down
4 changes: 1 addition & 3 deletions .api-reports/api-report-link_http.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ export class HttpLink extends ApolloLink {
constructor(options?: HttpOptions);
// (undocumented)
options: HttpOptions;
// (undocumented)
requester: RequestHandler;
}

// @public (undocumented)
Expand Down Expand Up @@ -278,7 +276,7 @@ type RequestHandler = (operation: Operation, forward: NextLink) => Observable<Fe
//
// @public (undocumented)
export function rewriteURIForGET(chosenURI: string, body: Body_2): {
parseError: any;
parseError: unknown;
newURI?: undefined;
} | {
newURI: string;
Expand Down
30 changes: 14 additions & 16 deletions .api-reports/api-report-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ namespace Cache_2 {
// (undocumented)
interface BatchOptions<TCache extends ApolloCache<any>, TUpdateResult = void> {
// (undocumented)
onWatchUpdated?: (this: TCache, watch: Cache_2.WatchOptions, diff: Cache_2.DiffResult<any>, lastDiff: Cache_2.DiffResult<any> | undefined) => any;
onWatchUpdated?: (this: TCache, watch: Cache_2.WatchOptions, diff: Cache_2.DiffResult<any>, lastDiff?: Cache_2.DiffResult<any> | undefined) => any;
// (undocumented)
optimistic?: string | boolean;
// (undocumented)
Expand Down Expand Up @@ -552,7 +552,7 @@ class Concast<T> extends Observable<T> {
// (undocumented)
cancel: (reason: any) => void;
// (undocumented)
readonly promise: Promise<T>;
readonly promise: Promise<T | undefined>;
// (undocumented)
removeObserver(observer: Observer<T>): void;
}
Expand Down Expand Up @@ -1021,15 +1021,13 @@ class LocalState<TCacheShape> {
// Warning: (ae-forgotten-export) The symbol "LocalStateOptions" needs to be exported by the entry point index.d.ts
constructor({ cache, client, resolvers, fragmentMatcher, }: LocalStateOptions<TCacheShape>);
// (undocumented)
addExportedVariables(document: DocumentNode, variables?: OperationVariables, context?: {}): Promise<{
[x: string]: any;
}>;
addExportedVariables<TVars extends OperationVariables>(document: DocumentNode, variables?: TVars, context?: {}): Promise<TVars>;
// (undocumented)
addResolvers(resolvers: Resolvers | Resolvers[]): void;
// (undocumented)
clientQuery(document: DocumentNode): DocumentNode | null;
// (undocumented)
getFragmentMatcher(): FragmentMatcher;
getFragmentMatcher(): FragmentMatcher | undefined;
// (undocumented)
getResolvers(): Resolvers;
// (undocumented)
Expand Down Expand Up @@ -1452,7 +1450,7 @@ class QueryInfo {
document: DocumentNode;
variables: Record<string, any> | undefined;
networkStatus?: NetworkStatus;
observableQuery?: ObservableQuery<any>;
observableQuery?: ObservableQuery<any, any>;
lastRequestId?: number;
}): this;
// (undocumented)
Expand All @@ -1476,7 +1474,7 @@ class QueryInfo {
// (undocumented)
notify(): void;
// (undocumented)
readonly observableQuery: ObservableQuery<any> | null;
readonly observableQuery: ObservableQuery<any, any> | null;
// (undocumented)
readonly queryId: string;
// (undocumented)
Expand All @@ -1486,7 +1484,7 @@ class QueryInfo {
// (undocumented)
setDiff(diff: Cache_2.DiffResult<any> | null): void;
// (undocumented)
setObservableQuery(oq: ObservableQuery<any> | null): void;
setObservableQuery(oq: ObservableQuery<any, any> | null): void;
// (undocumented)
stop(): void;
// (undocumented)
Expand Down Expand Up @@ -2206,18 +2204,18 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/cache/core/types/common.ts:100:3 - (ae-forgotten-export) The symbol "StorageType" needs to be exported by the entry point index.d.ts
// src/core/ApolloClient.ts:47:3 - (ae-forgotten-export) The symbol "UriFunction" needs to be exported by the entry point index.d.ts
// src/core/LocalState.ts:46:5 - (ae-forgotten-export) The symbol "FragmentMap" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:112:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:113:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:116:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:149:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:378:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:113:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:114:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:117:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:150:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:379:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/types.ts:158:3 - (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts
// src/core/types.ts:160:3 - (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts
// src/core/types.ts:178:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
// src/core/types.ts:205:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:191:3 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/react/hooks/useBackgroundQuery.ts:24:3 - (ae-forgotten-export) The symbol "FetchMoreFunction" needs to be exported by the entry point index.d.ts
// src/react/hooks/useBackgroundQuery.ts:25:3 - (ae-forgotten-export) The symbol "RefetchFunction" needs to be exported by the entry point index.d.ts
// src/react/hooks/useBackgroundQuery.ts:26:3 - (ae-forgotten-export) The symbol "FetchMoreFunction" needs to be exported by the entry point index.d.ts
// src/react/hooks/useBackgroundQuery.ts:27:3 - (ae-forgotten-export) The symbol "RefetchFunction" needs to be exported by the entry point index.d.ts
// src/utilities/graphql/DocumentTransform.ts:122:7 - (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)
Expand Down
26 changes: 12 additions & 14 deletions .api-reports/api-report-react_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ namespace Cache_2 {
// (undocumented)
interface BatchOptions<TCache extends ApolloCache<any>, TUpdateResult = void> {
// (undocumented)
onWatchUpdated?: (this: TCache, watch: Cache_2.WatchOptions, diff: Cache_2.DiffResult<any>, lastDiff: Cache_2.DiffResult<any> | undefined) => any;
onWatchUpdated?: (this: TCache, watch: Cache_2.WatchOptions, diff: Cache_2.DiffResult<any>, lastDiff?: Cache_2.DiffResult<any> | undefined) => any;
// (undocumented)
optimistic?: string | boolean;
// (undocumented)
Expand Down Expand Up @@ -491,7 +491,7 @@ class Concast<T> extends Observable<T> {
// (undocumented)
cancel: (reason: any) => void;
// (undocumented)
readonly promise: Promise<T>;
readonly promise: Promise<T | undefined>;
// (undocumented)
removeObserver(observer: Observer<T>): void;
}
Expand Down Expand Up @@ -819,15 +819,13 @@ class LocalState<TCacheShape> {
// Warning: (ae-forgotten-export) The symbol "LocalStateOptions" needs to be exported by the entry point index.d.ts
constructor({ cache, client, resolvers, fragmentMatcher, }: LocalStateOptions<TCacheShape>);
// (undocumented)
addExportedVariables(document: DocumentNode, variables?: OperationVariables, context?: {}): Promise<{
[x: string]: any;
}>;
addExportedVariables<TVars extends OperationVariables>(document: DocumentNode, variables?: TVars, context?: {}): Promise<TVars>;
// (undocumented)
addResolvers(resolvers: Resolvers | Resolvers[]): void;
// (undocumented)
clientQuery(document: DocumentNode): DocumentNode | null;
// (undocumented)
getFragmentMatcher(): FragmentMatcher;
getFragmentMatcher(): FragmentMatcher | undefined;
// (undocumented)
getResolvers(): Resolvers;
// (undocumented)
Expand Down Expand Up @@ -1256,7 +1254,7 @@ class QueryInfo {
document: DocumentNode;
variables: Record<string, any> | undefined;
networkStatus?: NetworkStatus;
observableQuery?: ObservableQuery<any>;
observableQuery?: ObservableQuery<any, any>;
lastRequestId?: number;
}): this;
// (undocumented)
Expand All @@ -1280,7 +1278,7 @@ class QueryInfo {
// (undocumented)
notify(): void;
// (undocumented)
readonly observableQuery: ObservableQuery<any> | null;
readonly observableQuery: ObservableQuery<any, any> | null;
// (undocumented)
readonly queryId: string;
// (undocumented)
Expand All @@ -1290,7 +1288,7 @@ class QueryInfo {
// (undocumented)
setDiff(diff: Cache_2.DiffResult<any> | null): void;
// (undocumented)
setObservableQuery(oq: ObservableQuery<any> | null): void;
setObservableQuery(oq: ObservableQuery<any, any> | null): void;
// (undocumented)
stop(): void;
// (undocumented)
Expand Down Expand Up @@ -1738,11 +1736,11 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/cache/core/types/common.ts:100:3 - (ae-forgotten-export) The symbol "StorageType" needs to be exported by the entry point index.d.ts
// src/core/ApolloClient.ts:47:3 - (ae-forgotten-export) The symbol "UriFunction" needs to be exported by the entry point index.d.ts
// src/core/LocalState.ts:46:5 - (ae-forgotten-export) The symbol "FragmentMap" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:112:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:113:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:116:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:149:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:378:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:113:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:114:5 - (ae-forgotten-export) The symbol "QueryInfo" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:117:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:150:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:379:7 - (ae-forgotten-export) The symbol "UpdateQueries" needs to be exported by the entry point index.d.ts
// src/core/types.ts:158:3 - (ae-forgotten-export) The symbol "ApolloError" needs to be exported by the entry point index.d.ts
// src/core/types.ts:160:3 - (ae-forgotten-export) The symbol "NetworkStatus" needs to be exported by the entry point index.d.ts
// src/core/types.ts:178:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
Expand Down
Loading
Loading