Skip to content

Commit

Permalink
fix(npm-resolver): types
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Aug 26, 2022
1 parent 60282ac commit d904b83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/npm-resolver/src/pickPackage.ts
Expand Up @@ -16,10 +16,8 @@ import pickPackageFromMeta from './pickPackageFromMeta'
import { RegistryPackageSpec } from './parsePref'

export interface PackageMeta {
'dist-tag': { [name: string]: string }
versions: {
[name: string]: PackageInRegistry
}
'dist-tags': Record<string, string>
versions: Record<string, PackageInRegistry>
cachedAt?: number
}

Expand Down
7 changes: 4 additions & 3 deletions packages/npm-resolver/src/pickPackageFromMeta.ts
Expand Up @@ -8,9 +8,9 @@ export default function (
spec: RegistryPackageSpec,
preferredVersionSelectors: VersionSelectors | undefined,
meta: PackageMeta
): PackageInRegistry {
): PackageInRegistry | null {
try {
let version!: string
let version!: string | null
switch (spec.type) {
case 'version':
version = spec.fetchSpec
Expand All @@ -22,6 +22,7 @@ export default function (
version = pickVersionByVersionRange(meta, spec.fetchSpec, preferredVersionSelectors)
break
}
if (!version) return null
const manifest = meta.versions[version]
if (manifest && meta['name']) {
// Packages that are published to the GitHub registry are always published with a scope.
Expand All @@ -44,7 +45,7 @@ function pickVersionByVersionRange (
meta: PackageMeta,
versionRange: string,
preferredVerSels?: VersionSelectors
) {
): string | null {
let versions: string[] | undefined
const latest = meta['dist-tags'].latest

Expand Down

0 comments on commit d904b83

Please sign in to comment.