Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/type guard renderer #226

Merged
merged 3 commits into from
Mar 3, 2023
Merged

feat/type guard renderer #226

merged 3 commits into from
Mar 3, 2023

Conversation

marcolink
Copy link
Collaborator

@marcolink marcolink commented Mar 2, 2023

Create a type-guard function for every content type

Example:

import type { Entry, EntryFields } from "contentful";
import type { SysWithContentTypeLinkId } from "TypeGuardTypes";

export interface TypeAnimalFields {
    bread: EntryFields.Symbol;
}

export type TypeAnimal = Entry<TypeAnimalFields>;

export function isTypeAnimal(entry: SysWithContentTypeLinkId): entry is TypeAnimal {
    return entry.sys.contentType.sys.id === 'animal'
}

cc @veu

@marcolink marcolink force-pushed the feat/type-guard-renderer branch 4 times, most recently from 3b5e299 to 9f6fe4b Compare March 3, 2023 07:52
@marcolink marcolink marked this pull request as ready for review March 3, 2023 13:08
@marcolink marcolink merged commit 7711b73 into master Mar 3, 2023
@marcolink marcolink deleted the feat/type-guard-renderer branch March 3, 2023 13:08
marcolink added a commit that referenced this pull request Mar 3, 2023
Create a type-guard function for every content type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant