Skip to content

Commit 00d7ca6

Browse files
authored
Fix: Explicitly Initialize Input Refs with null for Better Type Safety (#31)
### Summary This PR updates the initialization of `ref<HTMLInputElement>` references by explicitly setting them to `null`. ### Changes - Updated `ref<HTMLInputElement>()` to `ref<HTMLInputElement | null>(null)`, ensuring proper type safety. - Prevents potential runtime errors by making sure `passwordInput.value` and `currentPasswordInput.value` are never `undefined`. - Aligns with Vue best practices for handling template refs. ### Why? - Without explicit `null`, TypeScript infers `undefined`, leading to potential issues when accessing `.value`. - Ensures better predictability and avoids unnecessary runtime checks. This change improves overall code reliability and maintainability.
1 parent 254fc9c commit 00d7ca6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

resources/js/pages/settings/Password.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const breadcrumbItems: BreadcrumbItem[] = [
2525
},
2626
];
2727
28-
const passwordInput = ref<HTMLInputElement>();
29-
const currentPasswordInput = ref<HTMLInputElement>();
28+
const passwordInput = ref<HTMLInputElement | null>(null);
29+
const currentPasswordInput = ref<HTMLInputElement | null>(null);
3030
3131
const form = useForm({
3232
current_password: '',

0 commit comments

Comments
 (0)