Skip to content
Prev Previous commit
Next Next commit
Make as assertion rely on inference instead of hard-coded type casting
If anything changes in the typing of `ChangeCategory` or `unreleasedChanges` that make them inconsistent, this code will fail silently. Relying on type inference instead of explicit type casting will make these line a little less brittle.

- TODO: document and expound in MetaMask/contributor-docs#47
  • Loading branch information
MajorLift committed Oct 13, 2023
commit 8da9f215a13db6775d178968ff343144fc3f7ffb
4 changes: 3 additions & 1 deletion src/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ export default class Changelog {

const unreleasedChanges = this.#changes[unreleased];

for (const category of Object.keys(unreleasedChanges) as ChangeCategory[]) {
for (const category of Object.keys(
unreleasedChanges,
) as (keyof typeof unreleasedChanges)[]) {
if (releaseChanges[category]) {
releaseChanges[category] = [
...(unreleasedChanges[category] ?? []),
Expand Down