bloomreach / spa-sdk

Apache License 2.0
15 stars 16 forks source link

Typescript error on @bloomreach/vue3-sdk on import #31

Closed Bo-Yang-PDL closed 5 months ago

Bo-Yang-PDL commented 5 months ago

node: v18.7.0 nuxt: ^3.10.0, typescript: ^5.2.2 @bloomreach/spa-sdk: ^22.0.2 @bloomreach/vue3-sdk: ^22.0.2

We are getting the below typescript error on Nuxt app when interacting with @bloomreach/vue3-sdk

 ERROR(vue-tsc)  Could not find a declaration file for module '@bloomreach/vue3-sdk'. '....../node_modules/@bloomreach/vue3-sdk/dist/index.js' implicitly has an 'any' type.
  There are types at '....../node_modules/@bloomreach/vue3-sdk/typings.d.ts', but this result could not be resolved when respecting package.json "exports". The '@bloomreach/vue3-sdk' library may need to update its package.json or typings.

  > 1 | import { BrSdk } from '@bloomreach/vue3-sdk'
      |                       ^^^^^^^^^^^^^^^^^^^^^^
    2 |
    3 | export default defineNuxtPlugin((nuxtApp) => {
    4 |   nuxtApp.vueApp.use(BrSdk)

Found this article that provides solutions to make package.json exports work with TypeScript. Please take a look. Thank you. TypeScript and NPM package.json exports the 2024 way

joerideg commented 5 months ago

Hi @Bo-Yang-PDL , I've just adjusted this and the changes are up for internal review. Releasing it as soon as that is done.

joerideg commented 5 months ago

@Bo-Yang-PDL version 22.0.3 is released and should fix this problem. Could you please verify and close the issue if its fixed?

Bo-Yang-PDL commented 5 months ago

Hi @joerideg, it works for us. Thanks for fixing it!