auth0 / auth0-vue

Auth0 authentication SDK for Vue.js apps
Other
140 stars 27 forks source link

auth0-vue package is using '@vue/runtime-core' which breaks augmentation of type ComponentCustomProperties in vue apps. #426

Open frgr91 opened 1 month ago

frgr91 commented 1 month ago

Checklist

Description

In newer vue versions the global properties augmentation has changed from using '@vue/runtime-core' to 'vue'.

The incorrect global property augmentation:

declare module '@vue/runtime-core'{
  interface ComponentCustomProperties{
     // your global property type
  }
}

The correct global propery augmentation:

declare module 'vue' {
  interface ComponentCustomProperties{
     // your global property type
  }
}

It is described in the vue documentation here: https://vuejs.org/guide/typescript/options-api#augmenting-global-properties

Any package using the augmentation of '@vue/runtime-core' will break and override other packages.

The solution:

Change the module-declaration from '@vue/runtime-core' to 'vue'.

Reproduction

  1. Create a vue-project with typescript support and install the auth0-vue package.
  2. create a new 'global-types.d.ts' file with the following content:

declare module 'vue' { export interface ComponentCustomProperties { /**

Note: you must also add the property to your vue-instance in order for it to work when compiled: app.config.globalProperties.$myCustomProperty = 'Hi there'.

Additional context

If any other packages is using '@vue/runtime-core' to augment global property typings it will break the global property augmentation resulting in type-errors.

auth0-vue version

2.3.3

Vue version

3.5.11

Which browsers have you tested in?

Chrome

yannic-wtfoxtrot commented 1 month ago

For documentation: This should be fixed with #419

frgr91 commented 3 weeks ago

I see that this was merged into main, but will there be a new version on npm for this package to fix the issues in my repos? I don't quite understand the process of how this package is maintained and by who so sorry in advance if I'm missing something obvious.

andreasgangso commented 3 weeks ago

@tusharpandey13 can we get an npm release?

@frgr91 you can point to the latest github repo commit in your package.json while you wait.

"@auth0/auth0-vue": "github:auth0/auth0-vue#8443323"
frgr91 commented 3 weeks ago

@tusharpandey13 can we get an npm release?

@frgr91 you can point to the latest github repo commit in your package.json while you wait.

"@auth0/auth0-vue": "github:auth0/auth0-vue#8443323"

Thanks for the reply, I didn't get this to work in my pnpm monorepo/pipeline. It's not a big issue though, but hopefully this will be published on npm soon enough :)