-
Notifications
You must be signed in to change notification settings - Fork 542
Closed
Labels
help wantedExtra attention is neededExtra attention is neededtypescriptRelated to TypeScript implementationRelated to TypeScript implementationvue 3Related to the vue 3 adapterRelated to the vue 3 adapter
Description
Version:
@inertiajs/vue3version: 1.2.0
Describe the problem:
When I try to access my form on a generic model T with a key: keyof T, Typescript raised an issue.
Steps to reproduce:
<template>
<div>
<!-- Working -->
<div>{{ form[key] }}</div>
<!-- Working -->
<div>{{ model[genericKey] }}</div>
<!-- Type 'keyof T' cannot be used to index type 'DistributeRef<InertiaForm<T>> -->
<div>{{ genericForm[genericKey] }}</div>
</div>
</template>
<script setup lang="ts" generic="T extends object">
import { InertiaForm, useForm } from '@inertiajs/vue3';
const props = defineProps<{
model: T;
genericKey: keyof T;
}>();
// Test with non generic default values
const defaultValues = { name: 'Thibaud' };
const form = useForm(defaultValues);
const key = 'name' as keyof typeof defaultValues;
const genericForm: InertiaForm<T> = useForm(props.model);
</script>Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is neededtypescriptRelated to TypeScript implementationRelated to TypeScript implementationvue 3Related to the vue 3 adapterRelated to the vue 3 adapter