nuxt-authorization icon indicating copy to clipboard operation
nuxt-authorization copied to clipboard

Typescript TypeCheck errors with this package

Open geferon opened this issue 1 year ago • 3 comments

node_modules/nuxt-authorization/dist/runtime/components/Can.vue:10:48 - error TS2345: Argument of type 'Ability extends { original: (user: any, ...args: infer Args) => import("D:/Trabajo/NFC/website-public-nuxt/node_modules/nuxt-authorization/dist/utils/index").AuthorizerResponse; } ? Args : never' is not assignable to parameter of type 'Ability extends { original: (user: any, ...args: infer Args) => AuthorizerResponse; } ? Args : never'.
  Type 'unknown[]' is not assignable to type 'Ability extends { original: (user: any, ...args: infer Args) => AuthorizerResponse; } ? Args : never'.

const can = await allows(props.bouncerAbility, ...props.args)
                                                ~~~~~~~~~~~~~

node_modules/nuxt-authorization/dist/runtime/components/Cannot.vue:10:51 - error TS2345: Argument of type 'Ability extends { original: (user: any, ...args: infer Args) => import("D:/Trabajo/NFC/website-public-nuxt/node_modules/nuxt-authorization/dist/utils/index").AuthorizerResponse; } ? Args : never' is not assignable to parameter of type 'Ability extends { original: (user: any, ...args: infer Args) => AuthorizerResponse; } ? Args : never'.
  Type 'unknown[]' is not assignable to type 'Ability extends { original: (user: any, ...args: infer Args) => AuthorizerResponse; } ? Args : never'.

const cannot = await denies(props.bouncerAbility, ...props.args)
                                                   ~~~~~~~~~~~~~

Enabling typescript: {typeCheck: true} in nuxt.config.ts comes up with this error.

geferon avatar Jul 30 '24 22:07 geferon

I can confirm that this is an issue:

For more context:

transforming (6) ../node_modules/nuxt/dist/app/entry.jsnode_modules/nuxt-authorization/dist/runtime/components/Can.vue:12:48 - error TS2345: Argument of type 'PropsArgs' is not assignable to parameter of type 'Ability extends { original: (user: any, ...args: infer Args) => AuthorizerResponse; } ? Args : never'.
  Type 'unknown[]' is not assignable to type 'Ability extends { original: (user: any, ...args: infer Args) => AuthorizerResponse; } ? Args : never'.

12 const can = await allows(props.bouncerAbility, ...(props.args ?? [] as unknown as PropsArgs))
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/nuxt-authorization/dist/runtime/components/Cannot.vue:12:51 - error TS2345: Argument of type 'PropsArgs' is not assignable to parameter of type 'Ability extends { original: (user: any, ...args: infer Args) => AuthorizerResponse; } ? Args : never'.
  Type 'unknown[]' is not assignable to type 'Ability extends { original: (user: any, ...args: infer Args) => AuthorizerResponse; } ? Args : never'.

12 const cannot = await denies(props.bouncerAbility, ...(props.args ?? [] as unknown as PropsArgs))
                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 2 errors in 2 files.

Errors  Files
     1  node_modules/nuxt-authorization/dist/runtime/components/Can.vue:12
     1  node_modules/nuxt-authorization/dist/runtime/components/Cannot.vue:12

@Barbapapazes I also notice that running test and test:types throw errors.

i'm not sure if its related to the release of Nuxt 3.13.2 or vue 3.5

genu avatar Sep 16 '24 21:09 genu

@Barbapapazes should we close?

Psycarlo avatar Jun 23 '25 00:06 Psycarlo

Daniel could give the solution to solve this

https://github.com/nuxt/nuxt/issues/29263#issuecomment-3009000635

Barbapapazes avatar Jun 26 '25 16:06 Barbapapazes