Skip to content

Type-error between this module and what Sanity exports for blocks #64

Open
@isakgustavsen

Description

@isakgustavsen

When using the new export types CLI there is a conflict with what is typed here.Having looked at the type im not quite sure how to fix it, so adding an issue. Report copied from @nuxtjs/sanity where I first created the issue

Version

@nuxtjs/sanity": "^1.11.3
@sanity/client": "^6.18.0
Nuxt: 3.11.2

Reproduction

Used the new export types cli: Link

What is expected?

Types should match

What is actually happening?

Type 'BlockContent | undefined' is not assignable to type 'PortableTextBlock<PortableTextMarkDefinition, ArbitraryTypedObject | PortableTextSpan, string, string>[] | undefined'

Steps to reproduce

Export using guide and type query as described in module docs
const { data } = await useSanityQuery<Type>(query)

Additional information

Exported type looks like this:

export type BlockContent = Array<{
  children?: Array<{
    marks?: Array<string>
    text?: string
    _type: 'span'
    _key: string
  }>
  style?: 'normal' | 'h1' | 'h2' | 'h3' | 'h4' | 'blockquote'
  listItem?: 'bullet'
  markDefs?: Array<{
    href?: string
    _type: 'link'
    _key: string
  }>
  level?: number
  _type: 'block'
  _key: string
}>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions