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

Default link resolution has wrong types #2379

Open
flagoon opened this issue Nov 21, 2024 · 0 comments
Open

Default link resolution has wrong types #2379

flagoon opened this issue Nov 21, 2024 · 0 comments

Comments

@flagoon
Copy link

flagoon commented Nov 21, 2024

Actual Behaviour

Here's the method I'm using for getting data from Contentful:

export type EntriesWithSlug = TypePageSkeleton | TypeBlogPostSkeleton;

export const getEntryBySlug = (contentType) =>
  async (slug) => {
    const entries = await client.getEntries<EntriesWithSlug>({
      content_type: contentType,
      "fields.slug": slug,
      include: 3,
    });

    const entry = entries.items[0];
    return entry;
  };

In documentation, in ADVANCED.md file, is written, that by default, the links will be resolved, and the ones that can't be resolved, will be treated as unresolved. And when checking the Entry in app, the links are resolved, but the return types are treating all links as unresolved.

So I can use something like:

   const someLinkedEntry = entry.fields.linkedEntry.fields.name

But typescript will suggest that linedEntry is unresolved

  const unresolvedEntry = entry.fields.linkedEntry.sys... <- which is wrong

If I use chain modifier, like withoutLinkResolution or withoutUnresolvableLinks the entry data is precisely the same as the types.

Environment

  • Language Version: node 20.13.1
  • Package Manager Version: pnpm 9.12.3
  • Package Version: "contentful": "^11.2.0",
  • Which API are you using?: Delivery
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

No branches or pull requests

1 participant