Skip to content

Commit a81cc0d

Browse files
authored
refactor: remove unnecessary assertion (#357)
1 parent c6d7647 commit a81cc0d

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/components/AnimatedBackground.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,17 @@ export function AnimatedBackground() {
208208

209209
for (let a = 0; a < particles.length; a++) {
210210
for (let b = a; b < particles.length; b++) {
211-
const dx = particles[a]!.x - particles[b]!.x
212-
const dy = particles[a]!.y - particles[b]!.y
211+
const dx = particles[a].x - particles[b].x
212+
const dy = particles[a].y - particles[b].y
213213
const distance = Math.sqrt(dx * dx + dy * dy)
214214

215215
if (distance < maxDistance) {
216216
const opacity = (1 - distance / maxDistance) * 0.5
217217
ctx.strokeStyle = `rgba(100, 150, 255, ${opacity})`
218218
ctx.lineWidth = 0.5
219219
ctx.beginPath()
220-
ctx.moveTo(particles[a]!.x, particles[a]!.y)
221-
ctx.lineTo(particles[b]!.x, particles[b]!.y)
220+
ctx.moveTo(particles[a].x, particles[a].y)
221+
ctx.lineTo(particles[b].x, particles[b].y)
222222
ctx.stroke()
223223
}
224224
}
@@ -253,16 +253,16 @@ export function AnimatedBackground() {
253253
if (!canvas) throw new Error("Canvas is null (not initialized?)")
254254

255255
// Calculate direction vector
256-
const dx = targetX - gradientPoints[0]!.x
257-
const dy = targetY - gradientPoints[0]!.y
256+
const dx = targetX - gradientPoints[0].x
257+
const dy = targetY - gradientPoints[0].y
258258

259259
// Smooth movement using linear interpolation
260-
gradientPoints[0]!.x += dx * moveSpeed
261-
gradientPoints[0]!.y += dy * moveSpeed
260+
gradientPoints[0].x += dx * moveSpeed
261+
gradientPoints[0].y += dy * moveSpeed
262262

263263
// Adjust radius based on distance to target
264264
const distanceToTarget = Math.sqrt(dx * dx + dy * dy)
265-
gradientPoints[0]!.radius = Math.max(
265+
gradientPoints[0].radius = Math.max(
266266
canvas.width * 0.2,
267267
Math.min(canvas.width * 0.4, canvas.width * 0.3 + distanceToTarget * 0.1),
268268
)

src/theme/Navbar/MobileSidebar/Layout/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {Props} from '@theme/Navbar/MobileSidebar/Layout';
88
// See https://github.com/facebook/react/issues/17157
99
// See https://github.com/radix-ui/themes/pull/509
1010
function inertProps(inert: boolean) {
11-
const isBeforeReact19 = parseInt(version!.split('.')[0]!, 10) < 19;
11+
const isBeforeReact19 = parseInt(version.split('.')[0], 10) < 19;
1212
if (isBeforeReact19) {
1313
return {inert: inert ? '' : undefined};
1414
}

src/theme/SearchBar/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ import styles from '@easyops-cn/docusaurus-search-local/dist/client/client/theme
4343

4444
async function fetchAutoCompleteJS() {
4545
const autoCompleteModule = await import('@easyops-cn/autocomplete.js');
46-
const autoComplete = autoCompleteModule.default as any;
47-
if ((autoComplete as any).noConflict) {
48-
(autoComplete as any).noConflict();
49-
} else if ((autoCompleteModule as any).noConflict) {
50-
(autoCompleteModule as any).noConflict();
46+
const autoComplete = autoCompleteModule.default;
47+
if (autoComplete.noConflict) {
48+
autoComplete.noConflict();
49+
} else if (autoCompleteModule.noConflict) {
50+
autoCompleteModule.noConflict();
5151
}
5252
return autoComplete;
5353
}
@@ -263,7 +263,7 @@ export default function SearchBar(): JSX.Element {
263263

264264
if (focusAfterIndexLoaded.current) {
265265
const input = searchBarRef.current!;
266-
if ((input as any).value) {
266+
if (input.value) {
267267
search.current?.autocomplete.open();
268268
}
269269
input.focus();
@@ -311,7 +311,7 @@ export default function SearchBar(): JSX.Element {
311311
: false;
312312

313313
useEffect(() => {
314-
const searchBar = searchBarRef.current as any;
314+
const searchBar = searchBarRef.current;
315315
const domValue = searchBar?.value;
316316
if (domValue) {
317317
setInputValue(domValue);

0 commit comments

Comments
 (0)