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

Fix for Flow issues in SimpleCacheProvider #12942

Merged
merged 2 commits into from
May 30, 2018
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Fix lints
  • Loading branch information
flarnie committed May 30, 2018
commit e20fae52268edae0a36240b89521d44ca2d47950
14 changes: 7 additions & 7 deletions packages/simple-cache-provider/src/SimpleCacheProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Pending = 1;
const Resolved = 2;
const Rejected = 3;

type EmptyRecord<K, V> = {|
type EmptyRecord<K> = {|
status: 0,
suspender: null,
key: K,
Expand Down Expand Up @@ -62,7 +62,7 @@ type ResolvedRecord<K, V> = {|
*/
|};

type RejectedRecord<K, V> = {|
type RejectedRecord<K> = {|
status: 3,
suspender: null,
key: K,
Expand All @@ -78,10 +78,10 @@ type RejectedRecord<K, V> = {|
|};

type Record<K, V> =
| EmptyRecord<K, V>
| EmptyRecord<K>
| PendingRecord<K, V>
| ResolvedRecord<K, V>
| RejectedRecord<K, V>;
| RejectedRecord<K>;

type RecordCache<K, V> = {|
map: Map<K, Record<K, V>>,
Expand Down Expand Up @@ -128,7 +128,7 @@ if (__DEV__) {
const MAX_SIZE = 500;
const PAGE_SIZE = 50;

function createRecord<K, V>(key: K): EmptyRecord<K, V> {
function createRecord<K>(key: K): EmptyRecord<K> {
return {
status: Empty,
suspender: null,
Expand Down Expand Up @@ -227,7 +227,7 @@ export function createCache(invalidator: () => mixed): Cache {
return newHead;
}

function load<K, V>(emptyRecord: EmptyRecord<K, V>, suspender: Promise<V>) {
function load<K, V>(emptyRecord: EmptyRecord<K>, suspender: Promise<V>) {
const pendingRecord: PendingRecord<K, V> = (emptyRecord: any);
pendingRecord.status = Pending;
pendingRecord.suspender = suspender;
Expand All @@ -242,7 +242,7 @@ export function createCache(invalidator: () => mixed): Cache {
error => {
// Resource failed to load. Stash the error for later so we can throw it
// the next time it's requested.
const rejectedRecord: RejectedRecord<K, V> = (pendingRecord: any);
const rejectedRecord: RejectedRecord<K> = (pendingRecord: any);
rejectedRecord.status = Rejected;
rejectedRecord.suspender = null;
rejectedRecord.error = error;
Expand Down