Skip to content

fix(deps): exclude @types/* packages from component peer dependencies#10186

Open
davidfirst wants to merge 9 commits into
masterfrom
fix/exclude-types-from-component-peers
Open

fix(deps): exclude @types/* packages from component peer dependencies#10186
davidfirst wants to merge 9 commits into
masterfrom
fix/exclude-types-from-component-peers

Conversation

@davidfirst

Copy link
Copy Markdown
Member

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:

  • When a component is installed, its env is installed alongside it
  • Packages in env.jsonc peers become runtime dependencies of the env itself
  • Since @types/* packages are only needed for TypeScript compilation (handled by the env), components don't need them in their own dependencies

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.
Copilot AI review requested due to automatic review settings February 5, 2026 01:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread scopes/dependencies/dependencies/dependencies-loader/apply-overrides.ts Outdated
Copilot AI review requested due to automatic review settings February 5, 2026 22:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

@sonarqubecloud

sonarqubecloud Bot commented Feb 6, 2026

Copy link
Copy Markdown

Copilot AI review requested due to automatic review settings June 10, 2026 12:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 10, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0)

Grey Divider


Action required

1. Stale missing @types issue 🐞 Bug ≡ Correctness
Description
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.
Code

scopes/dependencies/dependencies/dependencies-loader/apply-overrides.ts[R661-670]

+    // @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;
+    }
Evidence
The new @types/* early-return path removes the dependency from dependency maps, but nothing updates
the missing-packages issue list. Missing packages are recorded into MissingPackagesDependenciesOnFs
during auto-detection and then propagated onto component.issues, which is used by status/tag flows;
leaving stale entries can therefore incorrectly mark the component as having tag-blocking issues.

scopes/dependencies/dependencies/dependencies-loader/apply-overrides.ts[653-670]
scopes/dependencies/dependencies/dependencies-loader/auto-detect-deps.ts[741-752]
scopes/dependencies/dependencies/dependencies-loader/dependencies-loader.ts[155-171]
components/component-issues/component-issue.ts[17-23]
scopes/component/status/status.main.runtime.ts[145-172]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### 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


Grey Divider

Previous review results

Review updated until commit f9964c2

Results up to commit f67480f


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
Results up to commit ec32978


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 11, 2026

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f67480f

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 11, 2026

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f9964c2

Comment on lines +661 to +670
// @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;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants