js-webflow-api icon indicating copy to clipboard operation
js-webflow-api copied to clipboard

`CollectionItem` id is optional

Open tomelliot opened this issue 8 months ago • 2 comments

Is it possible to have a CollectionItem without an id? The types say this is possible: https://github.com/webflow/js-webflow-api/blob/b40a6a12d7dc723ff01ccfeec1e6d30a5d5de73d/src/api/types/CollectionItem.ts#L16. That adds extra work to check the id exists when working with the SDK.

tomelliot avatar Apr 14 '25 14:04 tomelliot

Hi @tomelliot - are you running into errors creating a CMS Item without an ID?

zplata avatar Apr 18 '25 21:04 zplata

No the issue is in fetching CMS items and mapping them to another structure. I'm expecting they'll have an ID, but the types don't guarantee that (so I have to either type guard or ts-expect an error). I'm assuming in reality they will always have an ID - is that wrong?

tomelliot avatar Apr 19 '25 06:04 tomelliot