Skip to content

Commit

Permalink
Replace as T[] assertions with ?? []
Browse files Browse the repository at this point in the history
- `as` assertions intended to exclude an empty/nullable type can be replaced by a nullish coalescing operator converting nullable values into an acceptable empty value that doesn't pollute the variable's type signature.
- TODO: document and expound in MetaMask/contributor-docs#47
  • Loading branch information
MajorLift committed Oct 13, 2023
1 parent e8df1ec commit 53cf673
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function stringifyRelease(
const categorizedChanges = orderedChangeCategories
.filter((category) => categories[category])
.map((category) => {
const changes = categories[category] as string[];
const changes = categories[category] ?? [];
return stringifyCategory(category, changes);
})
.join('\n\n');
Expand Down Expand Up @@ -386,8 +386,8 @@ export default class Changelog {
for (const category of Object.keys(unreleasedChanges) as ChangeCategory[]) {
if (releaseChanges[category]) {
releaseChanges[category] = [
...(unreleasedChanges[category] as string[]),
...(releaseChanges[category] as string[]),
...(unreleasedChanges[category] ?? []),
...(releaseChanges[category] ?? []),
];
} else {
releaseChanges[category] = unreleasedChanges[category];
Expand Down

0 comments on commit 53cf673

Please sign in to comment.