Skip to content

Commit

Permalink
Fix check:tsc errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 16, 2025
1 parent 8feca58 commit 03d261c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
23 changes: 19 additions & 4 deletions src/shadow/arborist/lib/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,30 @@ import { arboristEdgeClassPath } from '../../npm-paths'

import type { Edge as BaseEdge, DependencyProblem } from '@npmcli/arborist'

type EdgeClass = Omit<BaseEdge, 'overrides' | 'reload'> & {
type EdgeClass = Omit<
BaseEdge,
| 'accept'
| 'detach'
| 'optional'
| 'overrides'
| 'peer'
| 'peerConflicted'
| 'rawSpec'
| 'reload'
| 'satisfiedBy'
| 'spec'
| 'to'
> & {
optional: boolean
overrides: SafeOverrideSet | undefined
peer: boolean
peerConflicted: boolean
rawSpec: string
get accept(): string | undefined
get spec(): string
get to(): SafeNode | null
new (...args: any): EdgeClass
detach(): void
reload(hard?: boolean): void
satisfiedBy(node: SafeNode): boolean
}
Expand Down Expand Up @@ -84,11 +99,11 @@ export class SafeEdge extends Edge {
this.reload(true)
}

get accept() {
override get accept() {
return this.#safeAccept
}

get bundled() {
override get bundled() {
return !!this.#safeFrom?.package?.bundleDependencies?.includes(this.name)
}

Expand Down Expand Up @@ -187,7 +202,7 @@ export class SafeEdge extends Edge {
return this.#safeTo
}

detach() {
override detach() {
this.#safeExplanation = null
// Patch replacing
// if (this.#safeTo) {
Expand Down
24 changes: 22 additions & 2 deletions src/shadow/arborist/lib/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,34 @@ import type { Node as BaseNode } from '@npmcli/arborist'

type NodeClass = Omit<
BaseNode,
| 'addEdgeIn'
| 'addEdgeOut'
| 'canDedupe'
| 'canReplace'
| 'canReplaceWith'
| 'deleteEdgeIn'
| 'edgesIn'
| 'edgesOut'
| 'from'
| 'hasShrinkwrap'
| 'inDepBundle'
| 'inShrinkwrap'
| 'integrity'
| 'isTop'
| 'matches'
| 'meta'
| 'name'
| 'overrides'
| 'packageName'
| 'parent'
| 'recalculateOutEdgesOverrides'
| 'resolve'
| 'resolveParent'
| 'root'
| 'updateOverridesEdgeInAdded'
| 'updateOverridesEdgeInRemoved'
| 'version'
| 'versions'
> & {
name: string
version: string
Expand All @@ -41,7 +61,7 @@ type NodeClass = Omit<
new (...args: any): NodeClass
addEdgeIn(edge: SafeEdge): void
addEdgeOut(edge: SafeEdge): void
canDedupe(preferDedupe: boolean): boolean
canDedupe(preferDedupe?: boolean): boolean
canReplace(node: SafeNode, ignorePeers?: string[]): boolean
canReplaceWith(node: SafeNode, ignorePeers?: string[]): boolean
deleteEdgeIn(edge: SafeEdge): void
Expand Down Expand Up @@ -115,7 +135,7 @@ export class SafeNode extends Node {
// root dependency brings peer deps along with it. In that case, we
// will go ahead and create the invalid state, and then try to resolve
// it with more tree construction, because it's a user request.
override canReplaceWith(node: SafeNode, ignorePeers?: string[]) {
override canReplaceWith(node: SafeNode, ignorePeers?: string[]): boolean {
if (this.name !== node.name || this.packageName !== node.packageName) {
return false
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/strings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function stringJoinWithSeparateFinalSeparator(
list: (string | undefined)[],
list: string[],
separator: string = ' and '
): string {
const values = list.filter(Boolean)
Expand All @@ -8,7 +8,7 @@ export function stringJoinWithSeparateFinalSeparator(
return ''
}
if (length === 1) {
return values[0]
return values[0]!
}
const finalValue = values.pop()
return `${values.join(', ')}${separator}${finalValue}`
Expand Down

0 comments on commit 03d261c

Please sign in to comment.