Microsoft/TypeScript

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

Open

#59,941 建立於 2024年9月11日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugDomain: Declaration EmitHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

🔎 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

貢獻者指南