Skip to content

Conversation

@davidfirst
Copy link
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
Copy link
Contributor

Copilot AI left a comment

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

Copilot AI review requested due to automatic review settings February 5, 2026 22:10
Copy link
Contributor

Copilot AI left a comment

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.

// 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/')) {
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The early return at line 654 prevents cleanup of @types/* packages from allDependencies arrays when they exist as component dependencies. This can occur when the iteration order processes 'devDependencies' or 'dependencies' before 'peerDependencies'.

For example, if an @types/* package appears in both env.jsonc devDependencies and peerDependencies:

  1. First iteration (devDependencies): package is added to allDependencies.devDependencies
  2. Second iteration (peerDependencies): handlePeerDependencyOverride deletes from allPackagesDependencies but returns early before reaching lines 657-666 which would filter it from allDependencies arrays

To fix this, move the @types/* package filtering logic from allDependencies.dependencies and allDependencies.devDependencies before the early return, similar to lines 657-666 but specifically for @types/* packages.

Suggested change
if (pkgName.startsWith('@types/')) {
if (pkgName.startsWith('@types/')) {
// Ensure @types/* is removed from all component dependency arrays, even if it was
// previously added as a dependency or devDependency before being seen as a peer.
this.allDependencies.dependencies = this.allDependencies.dependencies.filter(
(dep) => dep.packageName !== pkgName
);
this.allDependencies.devDependencies = this.allDependencies.devDependencies.filter(
(dep) => dep.packageName !== pkgName
);
this.allDependencies.peerDependencies = this.allDependencies.peerDependencies.filter(
(dep) => dep.packageName !== pkgName
);

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 6, 2026

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.

1 participant