core icon indicating copy to clipboard operation
core copied to clipboard

A declaration file cannot be imported without 'import type'

Open GreenmeisterDavid opened this issue 1 year ago • 2 comments

Describe the bug Adding the NuxtHub module to the latest version of Nuxt (3.13.2) gives an error when combined with vue-tsc typechecking. Output error;

 ERROR        
 ERROR(vue-tsc)  A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '/home/projects/github-tlv5io/node_modules/@nuxthub/core/dist/runtime/base/server/utils/hooks' instead?
 FILE  undefined:

undefined

[vue-tsc] Found 1 error. Watching for file changes.

Steps to reproduce Reproduction on StackBlitz: https://stackblitz.com/edit/github-tlv5io

Steps to reproduce the behavior:

  1. Start new nuxt project
  2. Add the nuxthub module using npx nuxi module add hub
  3. Add typescript and vue-tsc dev deps
  4. Set typechecking in nuxt.config.ts;
  typescript: {
      typeCheck: true,
    },
  1. Run dev (npm run dev)

Expected behavior No typescript errors.

GreenmeisterDavid avatar Sep 23 '24 09:09 GreenmeisterDavid

This seems related directly to the module builder as Nitro generate a import script in .nuxt/types/nitro-imports.d.ts

CleanShot 2024-09-24 at 17 38 25

atinux avatar Sep 24 '24 15:09 atinux

Same here on [email protected].

Downgrading to 3.13.1 resolves it for now

zacwebb avatar Oct 02 '24 12:10 zacwebb

Hi there, are there any workarounds available, or are you still on 3.13.1?

cernymatej avatar Nov 24 '24 00:11 cernymatej

I can't replicate this on Nuxt v3.15.2 and @nuxthub/core 0.8.13. Are you still encountering this issue?

------------------------------
- Operating System: Linux
- Node Version:     v22.13.0
- Nuxt Version:     3.15.2
- CLI Version:      3.20.0
- Nitro Version:    2.10.4
- Package Manager:  [email protected]
- Builder:          -
- User Config:      compatibilityDate, devtools, future, typescript, modules
- Runtime Modules:  @nuxthub/[email protected]
- Build Modules:    -
------------------------------

Image

RihanArfan avatar Jan 20 '25 17:01 RihanArfan

@RihanArfan Nope, it's been solved for me as well on these latest versions! Thanks 💚

GreenmeisterDavid avatar Jan 21 '25 11:01 GreenmeisterDavid