fix: typings

This commit is contained in:
Zoltan Kochan
2019-05-31 00:50:12 +03:00
parent 06dd69511c
commit bcc0fba43f
9 changed files with 12 additions and 11 deletions

View File

@@ -10,10 +10,12 @@ export type RootMessage = {
prefix: string,
} & ({
added: {
id?: string,
name: string,
realName: string,
version?: string,
dependencyType?: DependencyType,
latest?: string,
linkedFrom?: string,
},
} | {

View File

@@ -95,7 +95,7 @@ export default function (
)
return most.combine(
(pkgsDiff, packageJsons) => {
(pkgsDiff, packageJsons: { initial?: PackageJson, updated?: PackageJson }) => {
if (!packageJsons['initial'] || !packageJsons['updated']) return pkgsDiff
const initialPackageJson = removeOptionalFromProdDeps(packageJsons['initial'])

View File

@@ -427,7 +427,7 @@ async function linkRootPackages (
if (relDepPath === null) return
const pkgSnapshot = lockfile.packages && lockfile.packages[relDepPath]
if (!pkgSnapshot) return // this won't ever happen. Just making typescript happy
const pkgId = pkgSnapshot.id || depPath
const pkgId = pkgSnapshot.id || depPath || undefined
const pkgInfo = nameVerFromPkgSnapshot(relDepPath, pkgSnapshot)
rootLogger.debug({
added: {

View File

@@ -174,7 +174,6 @@ async function resolveAndFetch (
}
return {
body: {
cacheByEngine: options.sideEffectsCache ? await getCacheByEngine(ctx.storePath, id) : new Map(),
id,
isLocal: true,
manifest: pkg,
@@ -559,7 +558,7 @@ async function fetcher (
// TODO: cover with tests
export async function getCacheByEngine (storePath: string, id: string): Promise<Map<string, string>> {
const map = new Map()
const map = new Map<string, string>()
const cacheRoot = path.join(storePath, id, 'side_effects')
if (!await fs.exists(cacheRoot)) {

View File

@@ -21,7 +21,7 @@ export default async function linkIndexedDir (existingDir: string, newDir: strin
}
async function tryLinkIndexedDir (existingDir: string, newDir: string, filenames: string[]) {
const alldirs = new Set()
const alldirs = new Set<string>()
filenames
.forEach((f) => {
alldirs.add(path.join(newDir, path.dirname(f)))

View File

@@ -549,7 +549,7 @@ function sortPackages<T> (pkgGraph: {[nodeId: string]: PackageNode<T>}): string[
async function readLocalConfigs (prefix: string) {
try {
const ini = await readIniFile(path.join(prefix, '.npmrc'))
const ini = await readIniFile(path.join(prefix, '.npmrc')) as { [key: string]: string }
return camelcaseKeys(ini) as {[key: string]: string}
} catch (err) {
if (err.code !== 'ENOENT') throw err

View File

@@ -118,8 +118,8 @@ function copyPackageSnapshots (
},
): PackageSnapshots {
const copiedPackages: PackageSnapshots = {}
const nonOptional = new Set()
const notProdOnly = new Set()
const nonOptional = new Set<string>()
const notProdOnly = new Set<string>()
copyDependencySubGraph(copiedPackages, opts.devRelPaths, originalPackages, new Set(), opts.warn, {
dev: true,

View File

@@ -438,7 +438,7 @@ async function selectNewFromWantedDeps (
registries: Registries,
},
) {
const newDeps = new Set()
const newDeps = new Set<string>()
const prevRelDepPaths = new Set(R.keys(currentLockfile.packages))
await Promise.all(
wantedRelDepPaths.map(

View File

@@ -261,7 +261,7 @@ async function _rebuild (
})
})
const nodesToBuildAndTransitive = new Set()
const nodesToBuildAndTransitive = new Set<string>()
getSubgraphToBuild(pkgSnapshots, entryNodes, nodesToBuildAndTransitive, new Set(), { optional: opts.optional === true, pkgsToRebuild })
const nodesToBuildAndTransitiveArray = Array.from(nodesToBuildAndTransitive)
@@ -269,7 +269,7 @@ async function _rebuild (
const pkgSnapshot = pkgSnapshots[relDepPath]
graph.set(relDepPath, R.toPairs({ ...pkgSnapshot.dependencies, ...pkgSnapshot.optionalDependencies })
.map((pair) => dp.refToRelative(pair[1], pair[0]))
.filter((childRelDepPath) => nodesToBuildAndTransitive.has(childRelDepPath)))
.filter((childRelDepPath) => childRelDepPath && nodesToBuildAndTransitive.has(childRelDepPath)))
}
const graphSequencerResult = graphSequencer({
graph,