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]: GenericDocumentResponse has not public export #53

Open
2 of 3 tasks
AlexLyssenko opened this issue Feb 11, 2025 · 4 comments
Open
2 of 3 tasks

[feat]: GenericDocumentResponse has not public export #53

AlexLyssenko opened this issue Feb 11, 2025 · 4 comments
Labels
status: need research The feature or enhancement needs more research before being accepted

Comments

@AlexLyssenko
Copy link

Bug Description

If i use following TS code:


import { GenericDocumentResponse } from '@strapi/sdk-js/dist/types/content-api';

const response: GenericDocumentResponse = await collection.find({ locale: locale.locale, populate: ['catalog'] });

I get TS warning:
TS2307: Cannot find module @strapi/ sdk-js/ dist/ types/ content-api or its corresponding type declarations.

Could add GenericDocumentResponse in public export

Image

Steps to Reproduce

  1. "@strapi/sdk-js": "^1.0.0",
  2. import GenericDocumentResponse from @strapi/sdk-js/dist/types/content-api
  3. Should get TS warning

Expected Behavior

No TS warnings

Version

1.0.0

Operating System

Windows

Runtime Environment

Node.js

Logs

Media

No response

Confirmation Checklist

  • I have checked the existing issues
  • I agree to follow this project's Code of Conduct
  • I would like to work on this issue
@AlexLyssenko AlexLyssenko added issue: bug Issue reporting a bug status: to be confirmed The issue needs to be reproduced or confirmed by a team member labels Feb 11, 2025
@Convly Convly added status: need research The feature or enhancement needs more research before being accepted and removed issue: bug Issue reporting a bug status: to be confirmed The issue needs to be reproduced or confirmed by a team member labels Feb 11, 2025
@Convly Convly changed the title [bug]: GenericDocumentResponse has not public export [feat]: GenericDocumentResponse has not public export Feb 11, 2025
@Convly
Copy link
Member

Convly commented Feb 11, 2025

Hey, thanks for opening this issue.

The current behavior is actually the correct one. We're exporting types depending on precise needs to solve precise issues and try to avoid dumping all the internal types in the index.d.ts as it makes it harder to modify them in the future.

I've switched the issue to a feature request. In the meantime, could you elaborate the use cases and why you think it's important to give access to this type? I think I kinda get why it could be interesting to have them, but could you share a snippet where you would use this?

Thanks!

@AlexLyssenko
Copy link
Author

Hey, thanks for your answer: here small sample:
https://github.com/AlexLyssenko/strapi_warning/blob/main/src/index.ts

I need to add @ts-ignore to use typed GenericMultiDocumentResponse

Image

@Convly
Copy link
Member

Convly commented Feb 17, 2025

Yeah, that makes sense, however I'm not a fan of this type's name

We probably need to figure out a better public name to represent a generic document (or collection of document) response.

I'm not sure what offers the best DX:

import { Response } from '@strapi/client'

const doc: Response.Document;
const col: Response.DocumentCollection;

or

import { DocumentResponse, DocumentCollectionResponse } from '@strapi/client'

const doc: DocumentResponse;
const col: DocumentCollectionResponse;

or something completely different 🤔

@AlexLyssenko
Copy link
Author

I would go with
const doc: Response.Document;
const col: Response.DocumentCollection;
I could make PR for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: need research The feature or enhancement needs more research before being accepted
Projects
None yet
Development

No branches or pull requests

2 participants