Skip to content

arrays returned from useAsyncData and useFetch aren't typed properly #12099

@danielroe

Description

@danielroe

Environment


  • Operating System: Darwin
  • Node Version: v14.17.3
  • Nuxt Version: 3-3.0.0
  • Package Manager: Yarn
  • Bundler: Webpack
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Describe the bug

If an array type is provided, it gets improperly converted into a Pick type.

For example:

const { data } = useFetch<string, User[]>() // ...
// data is now typed as
Pick<User[], string>
// which is an impossible type

Reproduction

const { data } = useFetch<string, User[]>('test')
// this will give a type error
data.value.map(() => true)

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions