Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@swerder
Copy link
Contributor

@swerder swerder commented Jan 26, 2025

What does it do?

It allow to select the "documentId" in the strapi 5 document api inside selected "fields" without tricking the TypeScript to allow so.

Why is it needed?

The requests for documentId work and return the documentId, but the typescript check does not allow it, so need to trick TypeScript with unclean as any.

How to test it?

Have objects with references and only want to get the documentId of referenced object.
Do something like the following and verify TypeScript did not complain invalid documentId field.

const entry = await strapi.documents(contentType).findOne({
  documentId: entryId,
  fields: ['documentId'],
  populate: {
    operation: { fields: ['documentId', 'phase'], populate: { organization: { fields: ['documentId'] } } },
  },
});

Without the fix tricking TypeScript with contentType as any is required, but than loosing the IntelliSense help for possible fields and other checks / info.

@vercel
Copy link

vercel bot commented Jan 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
contributor-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 26, 2025 3:34pm

@strapi-cla
Copy link

strapi-cla commented Jan 26, 2025

CLA assistant check
All committers have signed the CLA.

@hanpaine hanpaine added pr: fix This PR is fixing a bug source: typescript Source is related to TypeScript (typings, tooling, ...) community Changes and fixes created by community members labels Feb 14, 2025
@hanpaine hanpaine moved this from To be reviewed (Open) to Reviewed in Developer Experience Squad Oct 30, 2025
@hanpaine hanpaine moved this from Reviewed to Scheduled in sprint in Developer Experience Squad Oct 30, 2025
@Bassel17 Bassel17 self-assigned this Nov 3, 2025
@Bassel17 Bassel17 self-requested a review November 3, 2025 11:31
Copy link
Member

@Bassel17 Bassel17 left a comment

Choose a reason for hiding this comment

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

LGTM!
thanks for the contribution

@vercel
Copy link

vercel bot commented Nov 3, 2025

@Bassel17 is attempting to deploy a commit to the Strapi Team on Vercel.

A member of the Team first needs to authorize it.

@Bassel17 Bassel17 merged commit a8b34ae into strapi:develop Nov 3, 2025
72 of 73 checks passed
@github-project-automation github-project-automation bot moved this from Scheduled in sprint to Fixed/Shipped in Developer Experience Squad Nov 3, 2025
@Bassel17 Bassel17 added this to the 5.30.1 milestone Nov 3, 2025
chaitya-titan pushed a commit to chaitya-titan/strapi that referenced this pull request Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Changes and fixes created by community members pr: fix This PR is fixing a bug source: typescript Source is related to TypeScript (typings, tooling, ...)

Projects

Status: Fixed/Shipped

Development

Successfully merging this pull request may close these issues.

4 participants