Fix typing of refs

This commit is contained in:
rijkvanzanten
2020-09-29 18:11:53 -04:00
parent f3f519e22e
commit 72fc6aee9c
6 changed files with 7 additions and 7 deletions

View File

@@ -61,10 +61,10 @@ function callHandlers(event: KeyboardEvent) {
export default function useShortcut(
shortcuts: string | string[],
handler: ShortcutHandler,
reference: Ref<HTMLElement | null> | Ref<Vue | null> = ref(document.body)
reference: Ref<HTMLElement | undefined> | Ref<Vue | undefined> = ref(document.body)
) {
const callback: ShortcutHandler = (event) => {
if (reference.value === null) return;
if (!reference.value) return;
const ref = reference.value instanceof HTMLElement ? reference.value : (reference.value.$el as HTMLElement);
if (

View File

@@ -212,7 +212,7 @@ export default defineComponent({
},
},
setup(props, { emit }) {
const table = ref<Vue | null>(null);
const table = ref<Vue>();
const mainElement = inject('main-element', ref<Element | null>(null));
const _selection = useSync(props, 'selection', emit);

View File

@@ -225,7 +225,7 @@ export default defineComponent({
},
},
setup(props) {
const form = ref(null);
const form = ref<HTMLElement>();
const userStore = useUserStore();
const { collection, primaryKey } = toRefs(props);

View File

@@ -232,7 +232,7 @@ export default defineComponent({
},
},
setup(props) {
const form = ref<HTMLElement | null>(null);
const form = ref<HTMLElement>();
const { primaryKey } = toRefs(props);
const { breadcrumb } = useBreadcrumb();
const fieldsStore = useFieldsStore();

View File

@@ -209,7 +209,7 @@ export default defineComponent({
},
},
setup(props) {
const form = ref<HTMLElement | null>(null);
const form = ref<HTMLElement>();
const fieldsStore = useFieldsStore();
const userStore = useUserStore();

View File

@@ -46,7 +46,7 @@ export default defineComponent({
},
},
setup(props) {
const textarea = ref<HTMLElement | null>(null);
const textarea = ref<HTMLElement>();
useShortcut('meta+enter', postComment, textarea);
const newCommentContent = ref<string | null>(null);
const saving = ref(false);