-
Notifications
You must be signed in to change notification settings - Fork 947
fix(deps): exclude @types/* packages from component peer dependencies #10186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
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
scopes/dependencies/dependencies/dependencies-loader/apply-overrides.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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/')) { |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
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:
- First iteration (devDependencies): package is added to allDependencies.devDependencies
- 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.
| 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 | |
| ); |
|



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