Skip to content

Commit ed83fae

Browse files
cmdcolinclaude
andcommitted
fix: add non-null assertions for noUncheckedIndexedAccess compliance
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent d0705d5 commit ed83fae

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/bgzFilehandle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ export default class BgzFilehandle {
5555
blockNum += 1
5656
) {
5757
const uncompressedBuffer = await this._readAndUncompressBlock(
58-
blockPositions[blockNum][0],
59-
blockPositions[blockNum + 1][0],
58+
blockPositions[blockNum]![0],
59+
blockPositions[blockNum + 1]![0],
6060
)
61-
const [, uncompressedPosition] = blockPositions[blockNum]
61+
const [, uncompressedPosition] = blockPositions[blockNum]!
6262
const sourceOffset =
6363
uncompressedPosition >= position ? 0 : position - uncompressedPosition
6464
const sourceEnd =

src/gziIndex.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ export default class GziIndex {
8585
return []
8686
}
8787
const entries = await this._getIndex()
88-
const relevant = []
88+
const relevant: ([number, number] | never[])[] = []
8989

9090
let lowerBound = 0
9191
let upperBound = entries.length - 1
9292
let searchPosition = Math.floor(entries.length / 2)
9393

9494
let comparison = compare(
9595
position,
96-
entries[searchPosition],
96+
entries[searchPosition]!,
9797
entries[searchPosition + 1],
9898
)
9999
while (comparison !== 0) {
@@ -105,17 +105,17 @@ export default class GziIndex {
105105
searchPosition = Math.ceil((upperBound - lowerBound) / 2) + lowerBound
106106
comparison = compare(
107107
position,
108-
entries[searchPosition],
108+
entries[searchPosition]!,
109109
entries[searchPosition + 1],
110110
)
111111
}
112112

113113
// here's where we read forward
114-
relevant.push(entries[searchPosition])
114+
relevant.push(entries[searchPosition]!)
115115
let i = searchPosition + 1
116116
for (; i < entries.length; i += 1) {
117-
relevant.push(entries[i])
118-
if (entries[i][UNCOMPRESSED_POSITION] >= endPosition) {
117+
relevant.push(entries[i]!)
118+
if (entries[i]![UNCOMPRESSED_POSITION] >= endPosition) {
119119
break
120120
}
121121
}

src/long.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ const TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL
33

44
export function longFromBytesToUnsigned(source: Uint8Array, i = 0) {
55
const low =
6-
source[i] |
7-
(source[i + 1] << 8) |
8-
(source[i + 2] << 16) |
9-
(source[i + 3] << 24)
6+
source[i]! |
7+
(source[i + 1]! << 8) |
8+
(source[i + 2]! << 16) |
9+
(source[i + 3]! << 24)
1010
const high =
11-
source[i + 4] |
12-
(source[i + 5] << 8) |
13-
(source[i + 6] << 16) |
14-
(source[i + 7] << 24)
11+
source[i + 4]! |
12+
(source[i + 5]! << 8) |
13+
(source[i + 6]! << 16) |
14+
(source[i + 7]! << 24)
1515
return (high >>> 0) * TWO_PWR_32_DBL + (low >>> 0)
1616
}

0 commit comments

Comments
 (0)