You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a quite dynamic way of handling "internal links" which I will explain:
import{DocumentTextIcon}from'@sanity/icons'import{defineField,defineType}from'sanity'import{portableTextField}from'../portable-text/portable-text.schema'exportconstpost=defineType({name: 'post',title: 'Posts',icon: DocumentTextIcon,type: 'document',options: {linkable: true,},fields: [defineField({name: 'title',title: 'Title',type: 'string',validation: (rule)=>rule.required(),}),defineField({name: 'slug',title: 'Slug',type: 'slug',description: 'A slug is required for the post to show up in the preview',options: {source: 'title',maxLength: 96,isUnique: (value,context)=>context.defaultIsUnique(value,context),},validation: (rule)=>rule.required(),}),portableTextField({includeHeadings: true,includeLinks: true,includeLists: true,}),],})
Now in my frontend I am using this to create a base portableTextQuery that we can reuse. The last is used only for creating a correct type with "all options".
Describe the bug
Opening a reference in a specific scenario just typegens to "null".
We have a quite dynamic way of handling "internal links" which I will explain:
The portableTextField function looks like this:
The internalLinkObject is like this:
Using a internalLink field:
Based on a linkableType export
Now in my frontend I am using this to create a base portableTextQuery that we can reuse. The last is used only for creating a correct type with "all options".
To Reproduce
Steps to reproduce the behavior:
Se reproduction here: https://github.com/heggemsnes/sanity-template-nextjs-clean/tree/internal-link-resolves-to-null
npm run extract-types
in studio foldernpm run typegen
in nextjs-app foldersanity-types.ts
under theFullPortableTextQueryTypeResult
around line 422Expected behavior
Be resolved to the actual type. Other places we use this we get the resolved value like:
(Example from bigger project)
Which versions of Sanity are you using?
@sanity/cli (global) 3.62.0 (latest: 3.64.2)
@sanity/assist 3.0.8 (up to date)
@sanity/eslint-config-studio 4.0.0 (up to date)
@sanity/icons 3.4.0 (up to date)
@sanity/vision 3.61.0 (latest: 3.64.2)
sanity 3.62.2 (latest: 3.64.2)
(Tested with 3.64.2 as well)
What operating system are you using?
MacOS 14.3.1
Which versions of Node.js / npm are you running?
10.2.4
v20.11.0
The text was updated successfully, but these errors were encountered: