quarrant / mobx-persist-store

Persist and rehydrate observable properties in mobx store.
270 stars 14 forks source link

Fix return type on readFromStorage #26

Closed codeBelt closed 3 years ago

codeBelt commented 3 years ago

When using TypeScript I am forced to return undefined for the write function. This PR changes the return type from undefined to void.

adapter: new StorageAdapter({
  read: async (name) => {
    ...
  },
  write: async (name, content) => {
    window.localStorage.setItem(name, JSON.stringify(content));

    return undefined; // Should not be force to return undefined
  }
}),

Changing to void

adapter: new StorageAdapter({
  read: async (name) => {
    ...
  },
  write: async (name, content) => {
    window.localStorage.setItem(name, JSON.stringify(content));
  }
}),
quarrant commented 3 years ago

@codeBelt You're write about write function and you're right about return type. But in the PR you're change readFromStorage function too

codeBelt commented 3 years ago

@quarrant you'r right. I am not sure why I did that. I reverted the changes to readFromStorage.

codeBelt commented 3 years ago

@quarrant Can you also create a new release for this merge so we can use the new types