Skip to content

Commit 3401147

Browse files
Clarify TypeScript noUncheckedIndexedAccess requirement for nullish coalescing
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
1 parent b06004b commit 3401147

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils/webAudioUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,16 @@ export function mixAudioBuffers(buffers: Float32Array[]): Float32Array {
132132
const len = Math.min(buffer.length, mixed.length);
133133
for (let i = 0; i < len; i++) {
134134
// Float32Array elements are initialized to 0 and accessed within bounds
135-
// TypeScript requires ?? 0 for array indexing even though values are always defined
135+
// ?? 0 required due to noUncheckedIndexedAccess: true in tsconfig.json
136136
mixed[i] = (mixed[i] ?? 0) + (buffer[i] ?? 0);
137137
}
138138
}
139139

140140
// Normalize by buffer count to prevent clipping
141141
const scale = 1 / buffers.length;
142142
for (let i = 0; i < mixed.length; i++) {
143-
mixed[i] = mixed[i] * scale;
143+
// ?? 0 required due to noUncheckedIndexedAccess: true in tsconfig.json
144+
mixed[i] = (mixed[i] ?? 0) * scale;
144145
}
145146

146147
return mixed;

0 commit comments

Comments
 (0)