nuxt-authorization
nuxt-authorization copied to clipboard
Typescript TypeCheck errors with this package
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.
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
@Barbapapazes should we close?
Daniel could give the solution to solve this
https://github.com/nuxt/nuxt/issues/29263#issuecomment-3009000635