Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destructuring from useStoryblok() no longer working in SDK 5.1.2 during build - Typescript error #1066

Open
nebrekab opened this issue Jan 21, 2025 · 0 comments

Comments

@nebrekab
Copy link

nebrekab commented Jan 21, 2025

storyblok.com

We have upgraded to the SDK 5.1.2 from 5.0.2, and the destructuring of the content value from the useStoryBlok() response is now throwing a Typescript build error.


Expected Behavior

No build error. :)

Current Behavior

We receive the following build error:

src/pages/hub/categories/[slug].astro:60:9 - error ts(2339): Property 'content' does not exist on type 'ISbStoryData<ISbComponentType<string> & { [index: string]: any; }> | null'.

const { content } = await useStoryblok(

Steps to Reproduce

  1. Create a project with Astro 5.1.7+, Vite 6.0+ and the Astro SDK 5.1.2
  2. Add some code to your Astro page (frontmatter/serverside code head area) fetch using useStoryblok() and try and destructured the content value - e.g.
---
import { useStoryblok } from '@storyblok/astro'
const {content} = await useStoryblok( 'cdn/stories', {version: 'draft'}, {}, Astro as any);
// access destructured var
console.log(content)
---
<p>Test page</p>
  1. run npm run build

You should now see the errors

package.json example:
package.json

The current solution we have is to remove destructuring, but it would be good to have this working again to simplify our code.

@nebrekab nebrekab changed the title Destructuring from useStoryblok() no longer working in SDK 5.1.2 during build Destructuring from useStoryblok() no longer working in SDK 5.1.2 during build - Typescript error Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant