Closed
Description
Consider the following components:
Form.svelte
:
<script lang="ts">
type TValues = $$Generic;
export let values: TValues;
type Errors<T> = {
[K in keyof T]: string;
};
let errors: Errors<TValues>;
</script>
<form>
<slot {errors} />
</form>
SpecialForm.svelte
:
<script lang="ts">
import Form from './Form.svelte';
type TValues = $$Generic;
export let values: TValues;
</script>
<Form
{values}
let:errors
>
<slot {errors} />
</Form>
App.svelte
:
<script lang="ts">
import SpecialForm from './SpecialForm.svelte';
let values: {
firstName: string;
lastName: string;
};
</script>
<SpecialForm
{values}
let:errors
>
{errors.firstName}
</SpecialForm>
In the last component (App.svelte
), the slot prop errors
doesn't have the right type, it's of type Errors<unknown>
even though the generic type is properly detected for values
.
I have quite a few components that have this kind of relationship, and generics are not working as expected currently, so I'd appreciate it if you fix this. Thank you.