-
Notifications
You must be signed in to change notification settings - Fork 46
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
Improved TypeScript definitions #543
Comments
Has there been any updates on this? Trying to get Storyblok, nextjs 13 with app router to work. Seeing this error during build: Code page.tsx: import {
getStoryblokApi, ISbStoriesParams
} from "@storyblok/react/rsc";
import StoryblokStory from "@storyblok/react/story";
export default async function Home() {
const { data } = await fetchData();
return (
<div>
<StoryblokStory story={data.story} />
</div>
)
}
export async function fetchData() {
let sbParams: ISbStoriesParams = { version: "draft" };
const storyblokApi = getStoryblokApi();
return storyblokApi.get(`cdn/stories/home`, sbParams);
} Here is the build error: npm run build
> [email protected] build
> next build
✓ Creating an optimized production build
✓ Compiled successfully
Linting and checking validity of types .Failed to compile.
.next/types/app/page.ts:8:13
Type error: Type 'OmitWithTag<typeof import("D:/Repos/testsite/src/app/page"), "metadata" | "default" | "config" | "generateStaticParams" | "revalidate" | "dynamic" | "dynamicParams" | "fetchCache" | "preferredRegion" | "runtime" | "maxDuration" | "generateMetadata", "">' does not satisfy the constraint '{ [x: string]: never; }'.
Property 'fetchData' is incompatible with index signature.
Type '() => Promise<ISbResult>' is not assignable to type 'never'.
6 |
7 | // Check that the entry is a valid entry
> 8 | checkFields<Diff<{
| ^
9 | default: Function
10 | config?: {}
11 | generateStaticParams?: Function
Linting and checking validity of types .. |
This package was incredibly useful for us for typing. I'm surprised it's not mentioned anywhere in the readme (it would be even more great if the module implemented this based on some options actually). |
I just opened a PR that should improve typing for the |
Still waiting for this in our year of the lord 2025... Would be awesome if the types were as easily found as they are in the react SDK. |
Description
As a developer I'd like to have better TypeScript definitions for the SDK. Currently a lot of things are just typed to
any
.Eg.
That just returns a
Promise<any>
rather than an indication of the type of data it returns. At the very least making it a generic would allow us to manually define the Story schema we're expecting.Suggested solution or improvement
Better TypeScript definitions. I can see from this project that there are underlying definitions used in the project but they're not exposed:
https://github.com/storyblok/storyblok-js-client/blob/main/src/interfaces.ts
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: