Skip to content

nuxi typecheck fails to detect h3 exports (maybe more) #1143

Closed as duplicate

Description

@amandesai01

Disable auto imports only for nitro.

// nuxt.config.ts
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2024-04-03',
  devtools: { enabled: false },
  nitro: {
    imports: {
      autoImport: false,
    },
  },
});

Manually import using #imports

// server/api/index.get.ts
import { defineEventHandler, getQuery } from '#imports';

export default defineEventHandler(async (event) => {
  const query = getQuery(event);
  return {
    ...query,
  };
});

VERIFY THAT IT WORKS AS EXPECTED
BUT, npx nuxi typecheck fails to detect this and complains.

❯ npx nuxi typecheck
server/api/index.get.ts:1:10 - error TS2305: Module '"#imports"' has no exported member 'defineEventHandler'.

1 import { defineEventHandler, getQuery } from '#imports';
           ~~~~~~~~~~~~~~~~~~

server/api/index.get.ts:1:30 - error TS2305: Module '"#imports"' has no exported member 'getQuery'.

1 import { defineEventHandler, getQuery } from '#imports';

Reproduction:
https://stackblitz.com/edit/nuxt-starter-vg7snjkv?file=server%2Fapi%2Findex.get.ts

Activity

  1. amandesai01 commented on Nov 28, 2025

    @amandesai01
    Author

    Actually it is unable to detect imports from a lot more libs

  2. amandesai01 commented on Nov 28, 2025

    @amandesai01
    Author

    I am using nuxt-auth-utils and getting this error:

    error TS2724: '"#imports"' has no exported member named 'setUserSession'. Did you mean 'useUserSession'?
    

    Key detail: useUserSession is only exported in #imports generated for frontend. This is my hint that it is not picking up correct #imports file. It is picking up frontend's file wherease it should have been backend one.

  3. amandesai01 commented on Dec 4, 2025

    @amandesai01
    Author

    any workaround or something? or may I know which exact repo does this issue belong? or is something similar already reported for me to track progress? any direction would be appreciated.

  4. danielroe commented on Dec 4, 2025

    @danielroe
    Member

    this is an inevitable consequence of nuxt/nuxt#33627 unfortunately.

    this won't happen with nitro v3 as it requires explicit imports, and otherwise we would consider going for #imports/nuxt and #imports/nitro

  5. cernymatej commented on Dec 25, 2025

    @cernymatej
    Member

    Wouldn't explicitly importing from h3 instead of #imports be an acceptable workaround for projects not using Nitro v3?

  6. danielroe commented on Dec 25, 2025

    @danielroe
    Member

    yes, and that is going to be the solution in nitro v3 as well (via nitro/h3 and we might even consider nuxt/h3)

  7. amandesai01 commented on Dec 28, 2025

    @amandesai01
    Author

    @cernymatej it's not just about h3 exports. It includes all the defined utils, nuxt auth utils, nitro runtime functions and so on...
    It would have been great if I could have just used #imports to import all these. But right now, adding typecheck to ci is far more important for me. Plus I can't fully use auto imports since nuxt test utils don't like it.

  8. cernymatej commented on Dec 28, 2025

    @cernymatej
    Member

    Let's track here: nuxt/nuxt#33979

  9. amandesai01 commented on Dec 28, 2025

    @amandesai01
    Author

    I might have misunderstood, but it's not just about endpoint files. All the server files.
    I have updated reproduction to accurately depict the issue.

  10. cernymatej commented on Dec 28, 2025

    @cernymatej
    Member

    hmm, interesting. I'll update the issue description. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions