openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

`SuccessResponseJSON` and `ErrorResponseJSON` always return `never`

Open piousdeer opened this issue 1 year ago • 1 comments

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 avatar Jul 28 '24 00:07 piousdeer

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 avatar Aug 14 '24 09:08 drwpow