Skip to content

Type inference and code execution interrupted by undocumented SerializeObject #1138

@tamutus

Description

@tamutus

Environment


  • Operating System: Windows_NT
  • Node Version: v18.15.0
  • Nuxt Version: 3.3.2
  • Nitro Version: 2.3.2
  • Package Manager: npm@9.6.2
  • Builder: vite
  • User Config: modules, app, components, routeRules, runtimeConfig
  • Runtime Modules: @nuxtjs/google-fonts@3.0.0
  • Build Modules: -

Reproduction

Somebody over in Nuxt issues made this, though the issue was closed in the Nuxt forum and explicitly deferred to Nitro, though I don't see a respective issue here (sorry if I missed it). Essentially, people including me are confused about how to exchange data from API to frontend because a mysterious SerializeObject type is wrapped around it. What will and won't be converted to this? how do we undo this or otherwise process this?

https://stackblitz.com/edit/github-xbwzpm?file=server%2Fapi%2Ftest.ts

Describe the bug

Specifically: When I write an API event handler that returns an array of a prisma type, and consume that type with the nuxt useFetch composable in the frontend, it's wrapped in SerializeObject<CorrectType[]>, and typescript says this backend data is unassignable to a variable of the type that was sent.

Additional context

Here's the Intellisense that is generated in VS Code
image

image

image

image

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions