Skip to content

Commit

Permalink
Fix Packument['versions'] type.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Sep 16, 2023
1 parent 2b599b4 commit f4a08f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/package-managers/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const fetchPackument = async (
opts: fetch.Options & {
fullMetadata?: boolean
},
): Promise<any> => {
): Promise<Packument> => {
const corgiDoc = 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*'
const fullDoc = 'application/json'
const headers = {
Expand Down Expand Up @@ -352,7 +352,7 @@ export const mockViewMany =
},
version,
// overwritten below
versions: [],
versions: {},
...(isPackument(partialPackument) ? partialPackument : null),
}

Expand All @@ -369,7 +369,9 @@ export const mockViewMany =
} as Index<string>)
: ({
...packument,
versions: [packument],
versions: {
[version]: packument,
},
} as Packument),
})),
)
Expand Down
5 changes: 4 additions & 1 deletion src/types/Packument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { Version } from './Version'

/** A pacote packument result object. */
export interface Packument {
_npmUser?: {
name: string
}
name: string
deprecated?: boolean
engines: {
Expand All @@ -12,5 +15,5 @@ export interface Packument {
// TODO: store only the time of the latest version?
time?: Index<string>
version: Version
versions: Packument[]
versions: Index<Packument>
}

0 comments on commit f4a08f5

Please sign in to comment.