Skip to content

feat(render): add 'IEntry' type containing all possible of entries#128

Merged
GabrielAnca merged 1 commit into
masterfrom
ga/add-all-entries-type
Nov 21, 2022
Merged

feat(render): add 'IEntry' type containing all possible of entries#128
GabrielAnca merged 1 commit into
masterfrom
ga/add-all-entries-type

Conversation

@GabrielAnca

Copy link
Copy Markdown
Contributor

I'm proposing adding an IEntry interface (open to discuss about naming 😄 ). This type would represent "an Entry coming from our Contentful instance."

In our case, we end up writing Entry<any> many times, especially in methods used for type checking:

function isHero(entry: Entry<any>): entry is IHero {
  return entry.sys.contentType?.sys.id === 'hero'
}

This allows us to be more specific on the type:

function isHero(entry: IEntry): entry is IHero {
  return entry.sys.contentType?.sys.id === 'hero'
}

@HoriaA HoriaA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

@GabrielAnca GabrielAnca changed the title Add IEntry type feat(render): add 'IEntry' type containing all possible of entries Nov 21, 2022
@GabrielAnca GabrielAnca merged commit 63ed374 into master Nov 21, 2022
@GabrielAnca GabrielAnca deleted the ga/add-all-entries-type branch November 21, 2022 17:14
@GabrielAnca

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 3.3.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