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

Fix/define type for json responses #1113

Closed

Conversation

paghar
Copy link
Contributor

@paghar paghar commented Nov 7, 2023

Summarize the changes made and the motivation behind them.

Reference related issues using # followed by the issue number.

If there are breaking API changes - like adding or removing props, or changing the structure of the theme - describe them, and provide steps to update existing code.

Copy link

vercel bot commented Nov 7, 2023

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

Name Status Preview Comments Updated (UTC)
flowbite-react ❌ Failed (Inspect) Nov 7, 2023 7:25pm

@paghar paghar force-pushed the fix/define-type-for-json-responses branch from c149b8b to b4d091a Compare November 7, 2023 19:21
@paghar
Copy link
Contributor Author

paghar commented Nov 7, 2023

Hi👋🏻@rluders
This PR is merge ready

@@ -1,4 +1,8 @@
export const safeResJson = (res: Response) => {
export interface JsonResponseType {
Copy link
Collaborator

Choose a reason for hiding this comment

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

thing is, we don't always know if the response is a plain Record, basically it can be anything.
I left it any because I needed to strongly type the responses of all API calls and I just didn't feel like doing it, derp.
Normally it should be typed as Promise<unknown> and unknown also extends T, which comes from the place where the function is fired.

@rluders what do u think about this? should we just merge the result to be "fale always" a Record?

@SutuSebastian
Copy link
Collaborator

deprecated by #1118

@rluders rluders closed this Nov 8, 2023
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

Successfully merging this pull request may close these issues.

3 participants