Skip to content

Autoimports' typeFrom property not used to generate declaration files #3669

Closed

Description

@8ctavio

Environment

Nitro: 2.12.7
Node: v20.12.1

export default defineNitroConfig({
  srcDir: "server",
  compatibilityDate: "2025-10-21",
  imports: {
    imports: [
      {
        name: "foo",
        from: resolve(import.meta.dirname, "./pkg/src/index.js"),
        typeFrom: resolve(import.meta.dirname, "./pkg/dts/index.d.ts"),
      },
    ],
  },
});

Reproduction

Reproduction link

  • Run pnpm prepare.
  • Inspect .nitro/types/nitro-imports.d.ts.
  • Look for a foo const; its type is string, but should be string | number | boolean (see pkg/dts/index.d.ts).

Describe the bug

Nitro does not use the typeFrom option of registered autoimports to generate declaration files, which may cause type declarations to not be found.

Nitro uses unimport's generateTypeDeclarations to generate declaration files' content, which supports the typeFrom option. However, a custom resolver that is missing typeFrom support is provided.

Additional context

Logs

Activity

  1. added
    pending triage
    on Oct 21, 2025
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

    pending triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions