Skip to content

TS6059 error while building project in monorepo setting #1709

Open

Description

@GabenGar

Problem

I have a browser extension project which depends on various packages within monorepo.
After updating to typescript 6 it doesn't build anymore due to resulting in errors like this:

ERROR in {package_module_path}
link-overwatch:build: [tsl] ERROR in {module_path}
link-overwatch:build:       TS6059: File {module_path} is not under 'rootDir' {extension_project_path}/src'. 'rootDir' is expected to contain all source files.
link-overwatch:build:   The file is in the program because:
link-overwatch:build:     Imported via {another_module_path} from file {module_path}
link-overwatch:build:     Root file specified for compilation

However it only triggers like this when building, during development it works just fine.

Reproduction

Install project

git clone https://github.com/GabenGar/todos
cd todos
# have to invoke prune with `npx` because it's called prior deps installation
# https://turborepo.dev/docs/reference/prune
npx turbo prune link-overwatch
cd out
npm ci

Run npm run dev-extension to start development mode, which will open a new firefox profile instance (so firefox is required). Possibly restart several times, since I haven't found the solution for starting web-ext in parallel but only after webpack produces output. But the point is it will work just fine and build on webpack side without path resolution errors.
Now run npm run build-extension and get bombarded with errors.
It couldn't be due webpack misconfiguration, because ts-loader gets used in both environments. There is also nothing inherently wrong with @repo/ui workspace structure, since its code is consumed by two other frontend projects, one isn't even using webpack. Nor I don't see any anomalies in tsconfig.json. So I assume the problem is ts-loader behaviour specifically with typescript 6+.

Activity

  1. johnnyreilly commented on Oct 1, 2026

    @johnnyreilly
    Member

    TypeScript behaviour changed with TS 6 and I think rootDir may have been one of the changes. Probably worth investigating that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions