Skip to content

Commit 34f9cee

Browse files
committed
Enable noUncheckedIndexedAccess
1 parent 3e425d0 commit 34f9cee

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ const getDraftState = (state: State, draftClick: DraftClick, mousePosition: Abso
3636
// Re-interpret as relative pattern.
3737
const draftPatternRelative = draftPattern satisfies AbsolutePattern as unknown as RelativePattern
3838

39-
let newDraft = getRelativePatternPosition(draftPatternRelative, state.screens[screenIndex])
39+
let newDraft = getRelativePatternPosition(draftPatternRelative, state.screens[screenIndex]!)
4040
for (const k of nestedPath) {
41-
newDraft = getRelativePatternPosition(newDraft, state.patterns[k])
41+
newDraft = getRelativePatternPosition(newDraft, state.patterns[k]!)
4242
}
4343

4444
return { ...state, patterns: state.patterns.concat(newDraft) }

src/draw.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const mapPatternToViewportSpace = (pattern: AbsolutePattern, screenSize: Size):
3737
target: mapPointToViewportSpace(pattern.target, screenSize),
3838
})
3939

40-
const getPatternPoints = <N extends PatternNumber>(pattern: Pattern<N>): Point<N>[] => {
40+
const getPatternPoints = <N extends PatternNumber>(pattern: Pattern<N>): [Point<N>, Point<N>, Point<N>, Point<N>] => {
4141
const { xMin, xMax, yMin, yMax } = getBoundariesFromPattern(pattern)
4242

4343
return [
@@ -126,7 +126,7 @@ const draw = (
126126
if (depth > MIN_DEPTH && globalMutableState.drawScreenCalls >= MAX_DRAW_CALLS) break
127127

128128
globalMutableState.drawScreenCalls += 1
129-
drawScreen(ctx, currentPattern, COLORS[Math.min(COLORS.length - 1, depth)])
129+
drawScreen(ctx, currentPattern, COLORS[Math.min(COLORS.length - 1, depth)]!)
130130

131131
for (const pattern of state.patterns) {
132132
const virtualScreen = combinePatterns(currentPattern, pattern)

src/functions.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const findClickedPattern = (
138138
let best: NestedPath | undefined = undefined
139139

140140
for (let i = 0; i < patterns.length; i++) {
141-
const newBasePattern = combinePatterns(previousBasePattern, patterns[i])
141+
const newBasePattern = combinePatterns(previousBasePattern, patterns[i]!)
142142
const newPath = path.concat(i)
143143

144144
const nestedResult = findClickedPattern(newBasePattern, patterns, point, newPath)
@@ -170,7 +170,8 @@ export const findClickedScreenOrPattern = (
170170

171171
let best: ClickedPath | undefined = undefined
172172
for (let i = 0; i < screens.length; i++) {
173-
const clickedPath = findClickedPattern(screens[i], patterns, point)
173+
const screen = screens[i]!
174+
const clickedPath = findClickedPattern(screen, patterns, point)
174175

175176
if (clickedPath !== undefined) {
176177
if (best === undefined || clickedPath.length > best.nestedPath.length) {
@@ -179,7 +180,7 @@ export const findClickedScreenOrPattern = (
179180
nestedPath: clickedPath,
180181
}
181182
}
182-
} else if (pointIsInPattern(point, screens[i])) {
183+
} else if (pointIsInPattern(point, screen)) {
183184
// only check current depth if there's no nested result
184185
if (best === undefined) {
185186
best = {

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"strict": true,
1919
"noUnusedLocals": true,
2020
"noUnusedParameters": true,
21-
"noFallthroughCasesInSwitch": true
21+
"noFallthroughCasesInSwitch": true,
22+
"noUncheckedIndexedAccess": true
2223
},
2324
"include": ["src"],
2425
"references": [{ "path": "./tsconfig.node.json" }]

0 commit comments

Comments
 (0)