Skip to content

Commit

Permalink
Fix types to avoid @ts-ignore (#951)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Sep 20, 2022
1 parent 64585ea commit 911f314
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions packages/assemble-release-plan/src/determine-dependents.ts
@@ -1,6 +1,5 @@
import semver from "semver";
import {
Release,
DependencyType,
PackageJSON,
VersionType,
Expand Down Expand Up @@ -123,36 +122,38 @@ export default function determineDependents({
pkgJSON: dependentPackage.packageJson,
};
})
.filter(({ type }) => type)
.forEach(
// @ts-ignore - I don't know how to make typescript understand that the filter above guarantees this and I got sick of trying
({ name, type, pkgJSON }: Release & { pkgJSON: PackageJSON }) => {
// At this point, we know if we are making a change
updated = true;
.filter(
(
dependentItem
): dependentItem is typeof dependentItem & { type: VersionType } =>
!!dependentItem.type
)
.forEach(({ name, type, pkgJSON }) => {
// At this point, we know if we are making a change
updated = true;

const existing = releases.get(name);
// For things that are being given a major bump, we check if we have already
// added them here. If we have, we update the existing item instead of pushing it on to search.
// It is safe to not add it to pkgsToSearch because it should have already been searched at the
// largest possible bump type.
const existing = releases.get(name);
// For things that are being given a major bump, we check if we have already
// added them here. If we have, we update the existing item instead of pushing it on to search.
// It is safe to not add it to pkgsToSearch because it should have already been searched at the
// largest possible bump type.

if (existing && type === "major" && existing.type !== "major") {
existing.type = "major";
if (existing && type === "major" && existing.type !== "major") {
existing.type = "major";

pkgsToSearch.push(existing);
} else {
let newDependent: InternalRelease = {
name,
type,
oldVersion: pkgJSON.version,
changesets: [],
};
pkgsToSearch.push(existing);
} else {
let newDependent: InternalRelease = {
name,
type,
oldVersion: pkgJSON.version,
changesets: [],
};

pkgsToSearch.push(newDependent);
releases.set(name, newDependent);
}
pkgsToSearch.push(newDependent);
releases.set(name, newDependent);
}
);
});
}

return updated;
Expand Down

0 comments on commit 911f314

Please sign in to comment.