E2E Type safety: What am I missing?

I'm exploring e2e type safety and am curious what I am missing. Here's my server route:
// server/api/test.ts
import type { User } from '~/types/user'

export default defineEventHandler(() => {
return { test: '0' } as User
})
// server/api/test.ts
import type { User } from '~/types/user'

export default defineEventHandler(() => {
return { test: '0' } as User
})
And I consume this on the client like so:
<script setup lang="ts">
import type { User } from './types/user'

const { data: userData } = await useFetch<User>('/api/test')
</script>
<script setup lang="ts">
import type { User } from './types/user'

const { data: userData } = await useFetch<User>('/api/test')
</script>
I have to explicitly state the expected return type from the useFetch hook. I assumed this would be inferred from the backend. Here's a reproduction: https://github.com/CodyBontecou/nuxt-e2e-types
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server