robinvdvleuten / vuex-persistedstate

💾 Persist and rehydrate your Vuex state between page reloads.
https://npm.im/vuex-persistedstate
MIT License
5.77k stars 379 forks source link

[bug] storage and key parameters #257

Closed WTDuck closed 4 years ago

WTDuck commented 4 years ago

Relevant code or config

export default function (
  options: Options | null,
  storage: Storage | null,  // UNUSED and mandatory
  key: string | null // UNUSED and mandatory
) {
  options = options || {};
  storage = options.storage || (window && window.localStorage);
  key = options.key || "vuex";
  ...
}

Problem: Since typescript implementations, storage and key parameters are now mandatory but not used in following assigned variables. Regular storage/key definition in options is still working

Suggested solution:

export default function (
  options?: Options | null,
  storage?: Storage | null,  // UNUSED and mandatory
  key?: string | null // UNUSED and mandatory
) {
  options = options || {};
  storage = options.storage || storage || (window && window.localStorage);
  key = options.key || key || "vuex";
  ...
}

Incoming PR for this code 😊

WTDuck commented 4 years ago

PR #258

robinvdvleuten commented 4 years ago

Thanks! The PR is merged!