nuxt-auth-utils: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file instead?


  • Operating System: Windows_NT
  • Node Version: v18.19.0
  • Nuxt Version: 3.13.2
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: pnpm@9.1.1
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

image

I have no idea why this happens now, but I can not work on my project, till I solve this.
I used auth utils for 2 months and didn’t have any issues.

This fixes the issue:

  "pnpm": {
    "overrides": {
      "vite-plugin-checker": "0.8.0",
      "vue-tsc": "2.0.29",
    }
  }

but introduces another error

image

I think this issue belongs in vue-tsc, but I just had issues with vue-tsc when I used auth utils.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 22 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Okay, here’s what I’ve found.

The error is caused by unimport generating the following code in .nuxt/nitro-imports.d.ts (and specifically the second line)

declare global {
  // @ts-ignore
  export type { OAuthAuth0Config } from '/project/node_modules/.pnpm/nuxt-auth-utils/node_modules/nuxt-auth-utils/dist/runtime/server/lib/oauth/auth0.d.ts'
  import('/project/node_modules/.pnpm/nuxt-auth-utils/node_modules/nuxt-auth-utils/dist/runtime/server/lib/oauth/auth0.d.ts')
}

This dynamic import() was added over a year ago and isn’t the issue - the issue is the extension (.d.ts) which should instead be .js (preferably) or omitted entirely. Although the TS error is only caused by the first line, the extension should be adjusted on both lines.

This issue likely needs to be resolved in unimport (cc: @antfu) unless these types are not meant to be globally available.

@atinux this should be good to close 👍

If you take out

typescript: {
    shim: false,
    typeCheck: true,
    strict: true,
  },

from https://stackblitz.com/edit/github-mmpbcp?file=nuxt.config.ts

the errors go away.

No errors: https://stackblitz.com/edit/github-mmpbcp-qxqvaj?file=nuxt.config.ts

The same issue. Maybe this is related with compatibilityVersion: 4 option?

Unfortunately not, this minimal reproduction is not set to compatibilityVersion: 4.

https://stackblitz.com/edit/github-mmpbcp?file=nuxt.config.ts

Got the exact same issue, not sure it’s a good idea to downgrade vue-tsc version

@MasterCarl instead, just upgrade unimport - that was where the issue was solved. (regenerating your lockfile should also work)

Just tried downgrading Typescript. It’s the same with 5.6.x. The latest version that doesn’t throw the error is 5.5.4.

Removing: typeCheck: true, disables type validation, so there are no errors, but there is also no validation.

FWIW, shim: false and strict: true are the defaults: https://nuxt.com/docs/api/nuxt-config#shim https://nuxt.com/docs/api/nuxt-config#strict

@atinux @stranavad it seems to originate from the addServerImportsDir call’s in the module.ts. Some of the exported types couse the error

I got the same issue.

Same here… had to make autoImport: false in a nuxt.config.ts to resolve issue