Skip to content

SuccessResponseJSON and ErrorResponseJSON always return never #1785

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

Closed
2 tasks
piousdeer opened this issue Jul 28, 2024 · 1 comment
Closed
2 tasks

SuccessResponseJSON and ErrorResponseJSON always return never #1785

piousdeer opened this issue Jul 28, 2024 · 1 comment
Labels
bug Something isn't working good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project openapi-ts Relevant to the openapi-typescript library PRs welcome PRs are welcome to solve this issue!

Comments

@piousdeer
Copy link
Contributor

Description

I think SuccessResponseJSON and ErrorResponseJSON weren't updated along with their non-JSON counterparts in v7 and they should've been something like this:

- export type JSONLike<T> = FilterKeys<T, `${string}/json`>;
+ export type JSONLike = `${string}/json`;

- export type SuccessResponseJSON<PathMethod> = JSONLike<SuccessResponse<ResponseObjectMap<PathMethod>>>;
+ export type SuccessResponseJSON<PathMethod> = SuccessResponse<ResponseObjectMap<PathMethod>, JSONLike>;
Name Version
openapi-typescript 7.1.0
Node.js v21.7.2
OS + version NixOS

Reproduction

import type { SuccessResponseJSON } from "openapi-typescript-helpers";

type x = SuccessResponseJSON<paths["/a/valid/path"]["get"]>; // `never`

type y = SuccessResponse<ResponseObjectMap<paths["/a/valid/path"]["get"]>>; // works

Checklist

@piousdeer piousdeer added bug Something isn't working openapi-ts Relevant to the openapi-typescript library labels Jul 28, 2024
@drwpow
Copy link
Contributor

drwpow commented Aug 14, 2024

That’s a good suggestion, and we’d welcome a PR for those. Those are just helper utils that people can use or not use, and we make no guarantees about breaking API changes. And if they can be improved like this, PRs are always welcome

@drwpow drwpow added PRs welcome PRs are welcome to solve this issue! good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project labels Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project openapi-ts Relevant to the openapi-typescript library PRs welcome PRs are welcome to solve this issue!
Projects
None yet
Development

No branches or pull requests

2 participants