I use pnpm with fully isolated dependencies of dependencies. I also have a rule for circular imports that are not type‑only, but somehow type‑only imports trigger the circular import rule.
After debugging I found trying to import typescript which fails because dependency-cruiser is does not list typescript as a dependency.
Expected Behavior
Using type-only should fail if typescript package is not available, and it should provide a clear error message explaining this.
Current Behavior
It ignores import type statements and does not detect them as type‑only imports.
Possible Solution
I resolved this issue by using a pnpm package extension:
"pnpm": {
"packageExtensions": {
"dependency-cruiser": {
"peerDependencies": {
"typescript": "*"
}
}
}
},
Perhaps dependency-cruiser should declare typescript in its peerDependencies?
Your Environment
- Version used: 17.3.9
- Node version: 22.14.0
- Typescript version: 5.9.3
- pnpm version: 10.14.0
Sorry, I cannot share my pnpm config because, in my environment, it’s not straightforward — I don’t use pnpm directly. Maybe on Saturday, I’ll try to create a minimal demo.
Thanks.
I use pnpm with fully isolated dependencies of dependencies. I also have a rule for circular imports that are not type‑only, but somehow type‑only imports trigger the circular import rule.
After debugging I found trying to import typescript which fails because
dependency-cruiseris does not listtypescriptas a dependency.Expected Behavior
Using
type-onlyshould fail iftypescriptpackage is not available, and it should provide a clear error message explaining this.Current Behavior
It ignores
import typestatements and does not detect them astype‑onlyimports.Possible Solution
I resolved this issue by using a pnpm package extension:
Perhaps
dependency-cruisershould declaretypescriptin itspeerDependencies?Your Environment
Sorry, I cannot share my pnpm config because, in my environment, it’s not straightforward — I don’t use pnpm directly. Maybe on Saturday, I’ll try to create a minimal demo.
Thanks.