kontent-ai / delivery-sdk-js

Kontent Delivery SDK for Javascript
https://kontent.ai
MIT License
50 stars 34 forks source link

Make Elements.RichTextElement generic #381

Closed dovca closed 2 days ago

dovca commented 10 months ago

Motivation

Much like the LinkedItemsElement, I would like to propose to add a type parameter to RichTextElement as well. Since you can limit the content type of components in rich texts, making the RichTextElement type generic in cooperation with kontent-ai/model-generator-js would increase type safety.

Proposed solution

export type RichTextElement<TContentItem extends IContentItem = IContentItem> = ElementModels.IElement<string> & {
    linkedItems: TContentItem[];
    ...
};
Enngage commented 10 months ago

Hi @dovca,

Yeah, this is definitely something I would like to do (along with some further type improvements). Im pretty busy with other work currently, but hopefully I'll be able to look into this at some point.