Skip to content

vue-tsc overwrite server imports with app imports #29263

@Barbapapazes

Description

@Barbapapazes

Environment


  • Operating System: Darwin
  • Node Version: v20.17.0
  • Nuxt Version: 3.13.2
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: pnpm@9.12.0
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

Barbapapazes/nuxt-authorization#12

Or

Clone the module https://github.com/Barbapapazes/nuxt-authorization, install deps, cd to the playground and run npm run typecheck

Describe the bug

This module provides utilities with the same name on both the app and the server.

This means that it's possible to import authorize from #imports in both the app and the server but this function does not have the same type definition (the server one use event. When running vue-tsc, it raises an error because it resolves server imports using app imports.

`vue-tsc` error

nuxt-authorization/playground on  main [✘!?] via ⬢ v20.17.0 
➜ nr typecheck 

> nuxt-authorization-playground@ typecheck /Users/esoub/dev/p/nuxt-authorization/playground
> nuxi typecheck

ℹ Running with compatibility version 4                                                               3:02:34 PM
server/api/products/[id].patch.ts:11:19 - error TS2345: Argument of type 'H3Event<EventHandlerRequest>' is not assignable to parameter of type 'BouncerAbility<any>'.
  Type 'H3Event<EventHandlerRequest>' is missing the following properties from type 'BouncerAbility<any>': original, execute, allowGuest

11   await authorize(event, editProduct, product)
                     ~~~~~

server/api/products/index.get.ts:4:19 - error TS2345: Argument of type 'H3Event<EventHandlerRequest>' is not assignable to parameter of type 'BouncerAbility<any>'.

4   await authorize(event, listProducts)
                    ~~~~~

server/api/products/index.post.ts:4:19 - error TS2345: Argument of type 'H3Event<EventHandlerRequest>' is not assignable to parameter of type 'BouncerAbility<any>'.

4   await authorize(event, createProduct)
                    ~~~~~


Found 3 errors in 3 files.

Errors  Files
     1  server/api/products/[id].patch.ts:11
     1  server/api/products/index.get.ts:4
     1  server/api/products/index.post.ts:4

[3:02:35 PM]  ERROR  Command failed with exit code 2: '/Users/esoub/dev/p/nuxt-authorization/node_modules/.pnpm/vue-tsc@2.1.6_typescript@5.5.4/node_modules/vue-tsc/bin/vue-tsc.js' --noEmit

  at getFinalError (/Users/esoub/dev/p/nuxt-authorization/node_modules/.pnpm/nuxi@3.14.0/node_modules/nuxi/dist/chunks/index3.mjs:1124:9)
  at makeError (/Users/esoub/dev/p/nuxt-authorization/node_modules/.pnpm/nuxi@3.14.0/node_modules/nuxi/dist/chunks/index3.mjs:3604:16)
  at getAsyncResult (/Users/esoub/dev/p/nuxt-authorization/node_modules/.pnpm/nuxi@3.14.0/node_modules/nuxi/dist/chunks/index3.mjs:7831:4)
  at handlePromise (/Users/esoub/dev/p/nuxt-authorization/node_modules/.pnpm/nuxi@3.14.0/node_modules/nuxi/dist/chunks/index3.mjs:7814:17)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async Object.run (/Users/esoub/dev/p/nuxt-authorization/node_modules/.pnpm/nuxi@3.14.0/node_modules/nuxi/dist/chunks/typecheck.mjs:81:7)
  at async runCommand$1 (/Users/esoub/dev/p/nuxt-authorization/node_modules/.pnpm/nuxi@3.14.0/node_modules/nuxi/dist/shared/nuxi.3e201632.mjs:1648:16)
  at async runCommand$1 (/Users/esoub/dev/p/nuxt-authorization/node_modules/.pnpm/nuxi@3.14.0/node_modules/nuxi/dist/shared/nuxi.3e201632.mjs:1639:11)
  at async runMain$1 (/Users/esoub/dev/p/nuxt-authorization/node_modules/.pnpm/nuxi@3.14.0/node_modules/nuxi/dist/shared/nuxi.3e201632.mjs:1777:7) 



[3:02:35 PM]  ERROR  Command failed with exit code 2: '/Users/esoub/dev/p/nuxt-authorization/node_modules/.pnpm/vue-tsc@2.1.6_typescript@5.5.4/node_modules/vue-tsc/bin/vue-tsc.js' --noEmit

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions