Skip to content

Improve types for builtin editor widget IDs#1462

Merged
Lisa White (whitelisab) merged 1 commit intocontentful:mainfrom
nib-bturner:overloading
Jan 31, 2025
Merged

Improve types for builtin editor widget IDs#1462
Lisa White (whitelisab) merged 1 commit intocontentful:mainfrom
nib-bturner:overloading

Conversation

@nib-bturner
Copy link
Contributor

Summary

Currently its pretty easy to mistype or put the wrong widgetId when changing editor interfaces. This PR introduces function overloading to the index.d.ts file to restrict this from string to the widget IDs listed in your website:
https://www.contentful.com/developers/docs/extensibility/app-framework/editor-interfaces/.

Description

Motivation and Context

I'm sick of guessing the wrong widgetId and would prefer a nicer developer experience. Copying these changes locally into our production application very clearly shows when there is an invalid widgetId for a builtin widget. Examples:

image

This catches these errors before they happen (number is not a valid widgetId)
image

Todos

  • Implemented feature
  • Feature with pending implementation

Screenshots (if appropriate):

@nib-bturner Brad Turner (nib-bturner) marked this pull request as ready for review January 30, 2025 00:58
@nib-bturner Brad Turner (nib-bturner) requested a review from a team as a code owner January 30, 2025 00:58
Copy link
Contributor

@whitelisab Lisa White (whitelisab) left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution Brad Turner (@nib-bturner)! This is a helpful DX improvement when working with the builtin widgetIds. Approving and merging! ⭐

@whitelisab Lisa White (whitelisab) merged commit 5a4086f into contentful:main Jan 31, 2025
6 checks passed
@nib-bturner Brad Turner (nib-bturner) deleted the overloading branch February 2, 2025 22:30
@contentful-automation
Copy link

🎉 This PR is included in version 4.28.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants