Skip to content

[Request]: Usage of Generated TypeScript Types in Frontend #1905

@sawden

Description

@sawden

Summary

Hello Strapi Team,

I am thrilled to see the new feature of generating TypeScript types for content in the recent version of Strapi as described in the documentation. This is a significant step towards type safety and better developer experience. However, I found that while the documentation covers the generation of types well, it lacks a practical example of how to utilize these generated types on the frontend side.

The only resource I could find regarding this topic was the blog post which provides the following snippet:

declare function fetch<T extends Common.UID.ContentType>(uid: T): Promise<Response<T>>;

I'm curious if there's a way to automatically map types to routes, avoiding specifying both like fetch<"api::page.page">("api/pages").
It would be incredibly helpful if the documentation could be expanded to include a best practice example showcasing how to leverage these generated types in the consuming frontend.

Thank you for your continuous effort in making Strapi a great CMS! 💪

Why is it needed?

A documentation with a best practice example are needed to help developers effectively utilize the TypeScript feature.

Suggested solution(s)

No response

Related issue(s)/PR(s)

No response

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