Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Typescript declaration files gets built in incorrect directory

Open
#854 8 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
build-system

Research direction

Start with the package.json declarations and the src/index.ts entry points in Projects A, B, and C, then inspect the microbundle and TypeScript configuration used across the Yarn workspace/Lerna packages. Reproduce the differing declaration output and trace why Project B writes build/project-b/src/index.d.ts. Done means every package emits its declaration at the configured build/index.d.ts path and downstream packages can resolve it.

Written by the indexing model from the issue text.

Description

I have three projects, Project A, Project B, and Project C that looks something like this:

Project A

// package.json
{
  "main": "build/index.js",
  "module": "build/index.modern.js",
  "types": "build/index.d.ts",
  "source": "src/index.ts",
}

The project outputs the declaration file correctly inside build/index.d.ts

Project B

// package.json
{
  "main": "build/index.js",
  "module": "build/index.modern.js",
  "types": "build/index.d.ts",
  "source": "src/index.ts",
  "dependencies": {
    "@my-workspace/project-a": "^1.0.0",
  },
}

The project INCORRECTLY outputs the declaration file inside build/project-b/src/index.d.ts.

Project C

// package.json
{
  "main": "build/index.js",
  "module": "build/index.modern.js",
  "types": "build/index.d.ts",
  "source": "src/index.ts",
  "dependencies": {
    "@my-workspace/project-b": "^1.0.0",
  },
}

This project fails to build because it can't find the declaration file for @my-workspace/project-b.

Issue

In my actual project I have 12 packages in a yarn workspace / lerna environment. The issue randomly happens for some projects and not others even though they all have the same microbundle and typescript config setup.

Dominant language
JavaScript
Stars
8.1k
Forks
358
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developit/microbundle

All issues in developit/microbundle

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.