storyblok / storyblok-js

JavaScript SDK to connect Storyblok with your favourite framework that we don't have an official SDK for.
http://storyblok.com/
MIT License
39 stars 20 forks source link

Generic Types for API results #571

Closed AdrianFahrbach closed 2 months ago

AdrianFahrbach commented 2 months ago

Description

The current API result types return data as any and therefore make it difficult to add types on the Storyblok clients that are based on this package.

Suggested solution or improvement

export interface ISbResult {
    data: any;
    perPage: number;
    total: number;
    headers: Headers;
}

Should be changed to:

export interface ISbResult<T> {
    data: T;
    perPage: number;
    total: number;
    headers: Headers;
}

Additional context

I'm not quire sure if there are other areas where types could benefit from generic types or if a change like this maybe is in the works already. If you can give me a bit of input on that, then I would be happy to open PRs here, in the JS client as well as in the Vue and React clients.

Validations

AdrianFahrbach commented 2 months ago

Nevermind, just noticed that this is the wrong repo for this request, since it just imports the types from the JS client.