KoesterJannik / sveltekit-repo-starter

41 stars 3 forks source link

Remove Typescript error thrown on Omit:<User...> extension #13

Open seantiz opened 2 months ago

seantiz commented 2 months ago

This is a minor error that doesn't break the app in any way, but I'm happy to contribute a PR to it if it makes sense.

When the User type is passed from Prisma into the AppShell component, it's passed with the hashed password parameter omitted and Typescript isn't sure about it from that point on, especially when AppShell is initialised in the +layout.svelte route later.

I modified +layout.svelte with data?.user explicitly typed

<script lang="ts">
    import AppShell from '../../../lib/components/layout/AppShell.svelte';
    import type { User } from '@prisma/client';
    export let data: { user: User };
</script>

<AppShell user={data?.user}>
    <slot />
</AppShell>

It seems to work as before, just without Typescript complaining now.

KoesterJannik commented 2 months ago

would you mind if you create a pr for that?