Skip to content

Generated d.ts imports package that is not installed on current projectΒ #59941

@baptisteArno

Description

@baptisteArno

πŸ”Ž Search Terms

"d.ts unresolved modules import"

πŸ•— Version & Regression Information

Typescript v5.5.4

⏯ Playground Link

No response

πŸ’» Code

Here is a basic reproduction: https://github.com/baptisteArno/zod-d-ts-issue

  1. pnpm install
  2. pnpm turbo build --filter=package-three...
  3. See error because schema is of type any

πŸ™ Actual behavior

package-two generates with imports from zod which package is not installed in package-two.

This means that the type that we get when importing things from package-two are of inferred type any

πŸ™‚ Expected behavior

I would expect the d.ts file to instead imports from installed packages only.

In that very specific case, I would expect it to generate:

export declare const schema: typeof import("package-one").schema

instead of

export declare const schema: import("zod").ZodObject<
  {
    id: import("zod").ZodString;
    name: import("zod").ZodString;
  },
  "strip",
  import("zod").ZodTypeAny,
  {
    id: string;
    name: string;
  },
  {
    id: string;
    name: string;
  }
>;

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions