microsoft / microsoft/TypeScript
Generated d.ts imports package that is not installed on current project
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
🔎 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
- pnpm install
- pnpm turbo build --filter=package-three...
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction at github.com/baptisteArno/zod-d-ts-issue, run pnpm install and pnpm turbo build --filter=package-three..., and inspect package-two's generated declaration. Trace how the compiler chooses imports for inferred declaration types; done means the declaration no longer requires the unavailable zod package and preserves the expected package-one reference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100