Skip to content

Commit

Permalink
Update optimism to use its new TypeScript declarations.
Browse files Browse the repository at this point in the history
Wow, I should have done this sooner. Super simple:
benjamn/optimism@03b3f88

Follow-up to #4158.
Should fix #4327.
  • Loading branch information
benjamn committed Jan 18, 2019
1 parent 4a220cd commit 29d09ab
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 36 deletions.
6 changes: 3 additions & 3 deletions packages/apollo-cache-inmemory/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/apollo-cache-inmemory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"dependencies": {
"apollo-cache": "file:../apollo-cache",
"apollo-utilities": "file:../apollo-utilities",
"optimism": "^0.6.8"
"optimism": "^0.6.9"
},
"peerDependencies": {
"graphql": "0.11.7 || ^0.12.0 || ^0.13.0 || ^14.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
export type OptimisticWrapperFunction<
T = (...args: any[]) => any
> = T & {
// The .dirty(...) method of an optimistic function takes exactly the same
// parameter types as the original function.
dirty: T;
};

export type OptimisticWrapOptions = {
max?: number;
disposable?: boolean;
makeCacheKey?(...args: any[]): any;
};

export { wrap } from 'optimism';

export class CacheKeyNode<KeyType = object> {
private children: Map<any, CacheKeyNode<KeyType>> | null = null;
private key: KeyType | null = null;
Expand All @@ -34,7 +18,7 @@ export class CacheKeyNode<KeyType = object> {
const map = this.children || (this.children = new Map());
let node = map.get(value);
if (!node) {
map.set(value, node = new CacheKeyNode<KeyType>());
map.set(value, (node = new CacheKeyNode<KeyType>()));
}
return node;
}
Expand Down
6 changes: 0 additions & 6 deletions packages/apollo-cache-inmemory/src/declarations.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/apollo-cache-inmemory/src/depTrackingCache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NormalizedCache, NormalizedCacheObject, StoreObject } from './types';
import { wrap, OptimisticWrapperFunction } from './optimism';
import { wrap, OptimisticWrapperFunction } from 'optimism';

const hasOwn = Object.prototype.hasOwnProperty;

Expand Down
9 changes: 4 additions & 5 deletions packages/apollo-cache-inmemory/src/inMemoryCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { DocumentNode } from 'graphql';

import { Cache, ApolloCache, Transaction } from 'apollo-cache';

import {
addTypenameToDocument,
} from 'apollo-utilities';
import { addTypenameToDocument } from 'apollo-utilities';

import { wrap } from 'optimism';

import { HeuristicFragmentMatcher } from './fragmentMatcher';
import {
Expand All @@ -18,9 +18,8 @@ import {

import { StoreReader } from './readFromStore';
import { StoreWriter } from './writeToStore';

import { DepTrackingCache } from './depTrackingCache';
import { wrap, CacheKeyNode } from './optimism';
import { CacheKeyNode } from './cacheKeys';
import { ObjectCache } from './objectCache';

export interface InMemoryCacheConfig extends ApolloReducerConfig {
Expand Down
5 changes: 2 additions & 3 deletions packages/apollo-cache-inmemory/src/readFromStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ import {
SelectionSetNode,
} from 'graphql';

import { wrap, CacheKeyNode } from './optimism';
export { OptimisticWrapperFunction } from './optimism';

import { wrap } from 'optimism';
import { CacheKeyNode } from './cacheKeys';
import { DepTrackingCache } from './depTrackingCache';

export type VariableMap = { [name: string]: any };
Expand Down

0 comments on commit 29d09ab

Please sign in to comment.