fix(deps): exclude @types/* packages from component peer dependencies#10186
fix(deps): exclude @types/* packages from component peer dependencies#10186davidfirst wants to merge 9 commits into
Conversation
When @types/* packages are listed as peers in env.jsonc, they should not be added to components' peer dependencies. The env is installed alongside the component and handles TypeScript compilation, so these type packages are already available without the component needing them directly.
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where @types/* packages listed as peer dependencies in env.jsonc were incorrectly being added to components' peer dependencies. Since these TypeScript type definition packages are only needed for compilation (handled by the environment), and the env is always installed alongside components, there's no need for components to declare them as their own dependencies.
Changes:
- Added logic to exclude
@types/*packages from component dependencies when they appear in env peer dependencies - Includes comprehensive inline documentation explaining the rationale
|
Code Review by Qodo
1. Stale missing @types issue
|
|
Code review by qodo was updated up to the latest commit f67480f |
|
Code review by qodo was updated up to the latest commit f9964c2 |
| // @types/* packages should not be added to components at all when in env peers. | ||
| // When a component is installed in a workspace, its env is installed as well. | ||
| // Packages listed as peers in env.jsonc become runtime dependencies of the env itself, | ||
| // so they're always installed alongside the env. Since @types/* packages are only needed | ||
| // for TypeScript compilation (which the env handles), there's no need for components | ||
| // to have them in their own dependencies. | ||
| if (pkgName.startsWith('@types/')) { | ||
| delete this.allPackagesDependencies.peerPackageDependencies[pkgName]; | ||
| return true; | ||
| } |
There was a problem hiding this comment.
1. Stale missing @types issue 🐞 Bug ≡ Correctness
handlePeerDependencyOverride() removes @types/* packages from the component dependency maps and returns early, but does not remove the same package from an already-populated MissingPackagesDependenciesOnFs issue. This can incorrectly keep the component in a tag-blocking “missing packages” state even though @types/* was intentionally excluded from the component dependencies.
Agent Prompt
### Issue description
When env peers include an `@types/*` package, `handlePeerDependencyOverride()` deletes the dependency entries and returns early. If `MissingPackagesDependenciesOnFs` already contains that `@types/*` package (e.g. the env hasn't been installed yet), the issue remains on the component even though the dependency was intentionally removed, potentially blocking tag.
### Issue Context
- `MissingPackagesDependenciesOnFs` is a tag-blocking issue by default.
- Current logic removes `@types/*` from `allPackagesDependencies` only, without cleaning existing issues data.
### Fix Focus Areas
- scopes/dependencies/dependencies/dependencies-loader/apply-overrides.ts[653-684]
### Suggested fix
- In `handlePeerDependencyOverride()`, before returning `true` for `@types/*`, remove `pkgName` from `MissingPackagesDependenciesOnFs` issue data:
- Filter `missingPackages` arrays to exclude `pkgName`
- Drop entries where `missingPackages` becomes empty
- If the issue data array becomes empty, delete the issue entirely (`this.issues.delete(IssuesClasses.MissingPackagesDependenciesOnFs)`)
- Keep the deletion from `allPackagesDependencies.*` as-is.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



When
@types/*packages are listed as peers in env.jsonc, they were incorrectly being added to components' peer dependencies.The fix excludes
@types/*packages from component dependencies entirely when they're in the env's peers. This is correct because:@types/*packages are only needed for TypeScript compilation (handled by the env), components don't need them in their own dependencies