Skip to content

Confusing error message when there is an accidental circular reference in monorepo #61577

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Jack-Works opened this issue Apr 14, 2025 · 5 comments
Labels
Unactionable There isn't something we can do with this issue

Comments

@Jack-Works
Copy link
Contributor

🔎 Search Terms

because it would overwrite input file

🕗 Version & Regression Information

  • This is the behavior in every version (5.8.3 and 5.9.0-dev.20250330) I tried, and I reviewed the FAQ for entries about "because it would overwrite input file"

⏯ Playground Link

https://github.com/Jack-Works/reproduce/tree/main/ts-accidental-circular-reference

💻 Code

git clone https://github.com/Jack-Works/reproduce/ --filter=blob:none
cd ts-accidental-circular-reference
code .
code ./b/src/index.ts
code ./b/tsconfig.json

🙁 Actual behavior

a error message that is not very helpful at b/tsconfig.json.

Cannot write file 'reproduce/ts-accidental-circular-reference/b/dist/index.d.ts' because it would overwrite input file.ts

🙂 Expected behavior

Despite the error message, tsc should give some helpful information so developers can figure out there is a circular project reference between a and b. Without this kind of information, circular reference is extremely hard to find out in a big monorepo

Additional information about the issue

No response

@RyanCavanaugh
Copy link
Member

There is no circular project reference graph here. a has no references https://github.com/Jack-Works/reproduce/blob/main/ts-accidental-circular-reference/a/tsconfig.json

@RyanCavanaugh RyanCavanaugh added the Unactionable There isn't something we can do with this issue label Apr 16, 2025
@Jack-Works
Copy link
Contributor Author

There is no circular project reference graph here. a has no references Jack-Works/reproduce@main/ts-accidental-circular-reference/a/tsconfig.json

There is one, https://github.com/Jack-Works/reproduce/blob/main/ts-accidental-circular-reference/a/src/index.ts a reference b without citing it in the a/tsconfig.json, which is an error, but this error is hard to find out if TypeScript gives an error message like this.

@RyanCavanaugh
Copy link
Member

I can't repro that behavior either. This is what I get when trying to infer what you were doing:

Before running pnpm install

D:\Throwaway\reproduce\ts-accidental-circular-reference>tsc -b
a/src/index.ts:1:19 - error TS2307: Cannot find module 'b' or its corresponding type declarations.

1 import { y } from 'b'
                    ~~~

b/src/index.ts:1:19 - error TS2307: Cannot find module 'a' or its corresponding type declarations.

1 import { x } from 'a'
                    ~~~


Found 2 errors.


D:\Throwaway\reproduce\ts-accidental-circular-reference>cd a

D:\Throwaway\reproduce\ts-accidental-circular-reference\a>tsc
src/index.ts:1:19 - error TS2307: Cannot find module 'b' or its corresponding type declarations.

1 import { y } from 'b'
                    ~~~


Found 1 error in src/index.ts:1


D:\Throwaway\reproduce\ts-accidental-circular-reference\a>cd ..\b

D:\Throwaway\reproduce\ts-accidental-circular-reference\b>tsc
src/index.ts:1:19 - error TS2307: Cannot find module 'a' or its corresponding type declarations.

1 import { x } from 'a'
                    ~~~


Found 1 error in src/index.ts:1

After running pnpm install

D:\Throwaway\reproduce\ts-accidental-circular-reference\a>tsc

D:\Throwaway\reproduce\ts-accidental-circular-reference\a>cd ..\b

D:\Throwaway\reproduce\ts-accidental-circular-reference\b>tsc

D:\Throwaway\reproduce\ts-accidental-circular-reference\b>cd ..

D:\Throwaway\reproduce\ts-accidental-circular-reference>tsc -b

@typescript-bot
Copy link
Collaborator

This issue has been marked as "Unactionable" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2025
@Jack-Works
Copy link
Contributor Author

@RyanCavanaugh hi! You need to use the VSCode language server. It appears in the language service. (It used to appears in the cli but I cannot find a minimal reproduce for CLI).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Unactionable There isn't something we can do with this issue
Projects
None yet
Development

No branches or pull requests

3 participants