greenpress / vuex-composition-helpers

A util package to use Vuex with Composition API easily.
https://www.npmjs.com/package/vuex-composition-helpers
MIT License
288 stars 32 forks source link

Fix compatibility with TypeScript 4.7.x #68

Closed LeSuisse closed 2 years ago

LeSuisse commented 2 years ago

TypeScript 4.7.x complains about the possible implicit conversion from symbol to string. Doing the conversion explicitly fixes the issues.

To reproduce the issue, you can upgrade the TypeScript version set as a dev dependency and then run the test suite. You will see error like this without this contribution:

 FAIL  tests/global-state.test.ts
  ● Test suite failed to run
    src/util.ts:52:48 - error TS2731: Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'.
    52   return cb(store, namespace ? `${namespace}/${prop}` : prop);
davidmeirlevy commented 2 years ago

Hi @LeSuisse !

Thanks for this contribution!! Would you mind just please to add a simple unit test, to check store usage using symbols?

It will make this improvement more resilient for future use cases.

Thanks!

LeSuisse commented 2 years ago

Would you mind just please to add a simple unit test, to check store usage using symbols?

Thanks for asking me to do that because I realized that making it work at runtime did not make a lot of sense. Symbols cannot be used for that since they cannot be serialized (https://github.com/vuejs/vuex/issues/303). I updated the type to exclude any symbol from the known keys.

Also, sorry for the noise in #69 I was not sure how you handle backports to the next branch.

davidmeirlevy commented 2 years ago

Thanks!

The "next" branch is almost completely different than the master branch, and needs a separate PR.