microsoft / microsoft/TypeScript
Add a specific error message for disallowed imports in project references?
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Suggestion
🔍 Search Terms
project reference back import
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
After introducing project references to a monolith repo with many developers, I've sometimes seen confusion over people writing imports from projects in the incorrect direction: e.g. if project B has a tsconfig reference to project A, trying to import from B in A. ♻️
https://github.com/JoshuaKGoldberg/ts-repro-back-reference-import
Here's an example error message that says what's technically wrong but doesn't give much context:
src/a/index.ts:1:19 - error TS6307: File '---/src/b/index.ts' is not listed within the file list of project '---/src/a/tsconfig.json'. Projects must list all files or use an 'include' pattern.
1 import { b } from "../b";
~~~~~~
📃 Motivating Example
Adding a specific error for these incorrect direction ("back") imports might help folks new to project references understand what they're doing wrong:
src/a/index.ts:1:19 - error TS6307: File '---/src/b/index.ts' is not listed within the file list of project '---/src/a/tsconfig.json'. Projects must list all files or use an 'include' pattern.
File "---/b/index.ts" is included in "---/b/tsconfig.json", but "---/a/tsconfig.json" does not list a reference to "---/b/tsconfig.json".
1 import { b } from "../b";
~~~~~~
💻 Use Cases
https://github.com/JoshuaKGoldberg/ts-repro-back-reference-import
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 by reproducing the back-reference import in the linked ts-repro-back-reference-import repository and inspect the involved tsconfig.json project references. Compare the existing TS6307 diagnostic with the proposed additional context, then identify the TypeScript compiler diagnostic and test locations that handle project-file inclusion. Done means the incorrect import produces a specific, actionable message without changing valid project-reference behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100