Update findOne method to use new document structure#2950
Merged
pwizla merged 3 commits intostrapi:mainfrom Feb 16, 2026
Merged
Conversation
I messed arround with this for way too long now.
the documentation is just wrong it seems...
Without the `as any` I get the following type errors:
```
Argument of type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to parameter of type 'WithStrapiCallback<PartialWithThis<Partial<CollectionType> & Generic>>'.
Type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type '<S extends { strapi: Core.Strapi; }>(params: S) => PartialWithThis<Partial<CollectionType> & Generic>'.
Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'PartialWithThis<Partial<CollectionType> & Generic>'.
Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'Partial<Partial<CollectionType> & Generic>'.
The types returned by 'findOne(...)' are incompatible between these types.
Type 'Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>' is not assignable to type 'Promise<AnyDocument>'.
Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type 'AnyDocument'.
Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type '{ documentId: string; id: number; }'.
Types of property 'id' are incompatible.
Type 'ID' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.ts(2345)
```
Just boiling down to a ID type mismatch..
In the typings this type is just not up to date:
```
export type AnyDocument = {
documentId: string;
id: number;
} & {
[key: string]: any;
};
```
Which should be:
```
export type AnyDocument = {
documentId: string;
id: number | string;
} & {
[key: string]: any;
};
```
|
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
pwizla
reviewed
Feb 16, 2026
pwizla
reviewed
Feb 16, 2026
pwizla
approved these changes
Feb 16, 2026
Collaborator
pwizla
left a comment
There was a problem hiding this comment.
Thank you, @Bellian!
There was a small typo (probably a copy/paste error) + I added comments for super.
The PR is now approved, merged, should be live on docs.strapi.io in a few minutes, and will be mentioned in the next weekly snapshot release.
pwizla
added a commit
that referenced
this pull request
Feb 16, 2026
* Update findOne method to use new document structure
I messed arround with this for way too long now.
the documentation is just wrong it seems...
Without the `as any` I get the following type errors:
```
Argument of type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to parameter of type 'WithStrapiCallback<PartialWithThis<Partial<CollectionType> & Generic>>'.
Type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type '<S extends { strapi: Core.Strapi; }>(params: S) => PartialWithThis<Partial<CollectionType> & Generic>'.
Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'PartialWithThis<Partial<CollectionType> & Generic>'.
Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'Partial<Partial<CollectionType> & Generic>'.
The types returned by 'findOne(...)' are incompatible between these types.
Type 'Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>' is not assignable to type 'Promise<AnyDocument>'.
Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type 'AnyDocument'.
Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type '{ documentId: string; id: number; }'.
Types of property 'id' are incompatible.
Type 'ID' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.ts(2345)
```
Just boiling down to a ID type mismatch..
In the typings this type is just not up to date:
```
export type AnyDocument = {
documentId: string;
id: number;
} & {
[key: string]: any;
};
```
Which should be:
```
export type AnyDocument = {
documentId: string;
id: number | string;
} & {
[key: string]: any;
};
```
* Apply suggestion from @pwizla
* Apply suggestion from @pwizla
---------
Co-authored-by: Pierre Wizla <pwizla+github@gmail.com>
pwizla
added a commit
that referenced
this pull request
Feb 16, 2026
* Update findOne method to use new document structure
I messed arround with this for way too long now.
the documentation is just wrong it seems...
Without the `as any` I get the following type errors:
```
Argument of type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to parameter of type 'WithStrapiCallback<PartialWithThis<Partial<CollectionType> & Generic>>'.
Type '<S extends { strapi: Core.Strapi; }>({ strapi }: S) => { findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type '<S extends { strapi: Core.Strapi; }>(params: S) => PartialWithThis<Partial<CollectionType> & Generic>'.
Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'PartialWithThis<Partial<CollectionType> & Generic>'.
Type '{ findOne(documentId: string, params?: object): Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>; }' is not assignable to type 'Partial<Partial<CollectionType> & Generic>'.
The types returned by 'findOne(...)' are incompatible between these types.
Type 'Promise<{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }>' is not assignable to type 'Promise<AnyDocument>'.
Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type 'AnyDocument'.
Type '{ id: ID; documentId: string; locale?: string; name?: string; createdAt?: DateTimeValue; publishedAt?: DateTimeValue; slug?: string; theme?: JSONValue; updatedAt?: DateTimeValue; }' is not assignable to type '{ documentId: string; id: number; }'.
Types of property 'id' are incompatible.
Type 'ID' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.ts(2345)
```
Just boiling down to a ID type mismatch..
In the typings this type is just not up to date:
```
export type AnyDocument = {
documentId: string;
id: number;
} & {
[key: string]: any;
};
```
Which should be:
```
export type AnyDocument = {
documentId: string;
id: number | string;
} & {
[key: string]: any;
};
```
* Apply suggestion from @pwizla
* Apply suggestion from @pwizla
---------
Co-authored-by: Bellian <cv.jsobotta@googlemail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I messed arround with this for way too long now.
the documentation is just wrong it seems...
Without the
as anyI get the following type errors:Just boiling down to a ID type mismatch..
In the typings this type is just not up to date:
Which should be:
Also
this.getFetchParamsdoes not exist if you do not also modify the method.. so you need to access this from thesuperobject.Related issue(s)/PR(s)
Let us know if this is related to any issue/pull request or contribution idea suggested by the Docs team.