Skip to content

TypeScript fails to find declaration file of a peer project after it rebuilds in a monorepo #61610

Open
@anthonyma94

Description

@anthonyma94

πŸ”Ž Search Terms

monorepo, ts7016, build, peer, project builds

πŸ•— Version & Regression Information

  • TypeScript v5.7.3

⏯ Playground Link

No response

πŸ’» Code

packages/sandbox/index.ts (app)

import { createLogger } from "@dmca/utils/logger";

(async function () {
    const [logger] = createLogger(undefined, "local");

    console.log("done.");
})();

packages/sandbox/package.json

{
  "name": "@dmca/sandbox",
  "dependencies": {
    "@dmca/utils": "workspace:^"
  }
}

libs/utils/package.json (library)

{
  "name": "@dmca/utils",
  "exports": {
    "./logger": {
      "types": "./dist/logger/index.d.ts",
      "default": "./dist/logger/index.js"
    },
  }
}

libs/utils/src/logger/index.ts

export const createLogger = () => {
  ...
}
...

πŸ™ Actual behavior

index.ts.-.dmca-aws.Dev.Container_.DMCA.AWS.@.code-server.-.Visual.Studio.Code.2025-04-23.15-30-32.mp4

I'm using a monorepo via pnpm workspaces with TypeScript 5.7.3. Libraries have an exports field in package.json that point to a compiled version of it. Whenever I recompile the library, all references to it fails with the error Could not find a declaration file for module "@module". path-to-compiled-js implicitly has an any type., until I either restart tsserver or delete and re-add the reference. The video shows the error process.

πŸ™‚ Expected behavior

I expect tsserver not to fail.

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions