Skip to content

Type narrowing not working with current setup #130

@programm-ingovals

Description

@programm-ingovals

Using the generated types I assume that type narrowing would work fine.

const embeddedEntry = (entry: IEntry) => {
  switch (entry.sys.contentType.sys.id) {
    case 'article':
      entry.fields // Should be known as IArticleFields here
      break
    case 'page':
      entry.fields  // Should be known as IPageFields here
}

Weirdly this does not seem to work, even though IArticleEntry should be the only one to have sys.contentType.sys.id as "article".
Is it because of the generic typing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions