Closed Darhagonable closed 9 months ago
You can access them via Parameters<typeof MyService.operationName>[0]
I believe, does that work for you?
Thats what im currently doing. It works but is more verbose. Exporting those types would be a nice to have though :P
@Darhagonable Done! For now I literally export the types that were there, maybe in the future it would make more sense to organise them into a separate types
folder
@mrlubos types like this no longer seem to be exported or am i missing some migration step at some point?
Are you able to import $OpenApiTs
from types.gen
? Just be warned this API isn't finalised yet and may change. I personally tend to use service classes to get to response or payload types - ReturnType<typeof DefaultService.foo>
@mrlubos Yes i can import $OpenApiTs
.
So if I'm understanding correctly TDataGetApiV1Foo
has been changed to $OpenApiTs["/api/v1/foo"]["get"]["req"]
?
Should probably be added to the migrations docs.
Seems then that the verbose ReturnType
useage is the preferred option indeed.
That sounds right. Honestly, you might be the only person using those types right now, since in the past you couldn't get to them in any other way than ReturnType<typeof DefaultService.foo>
which is why I started using that. Of course, there might be times when you don't want to pull in the service import to your file. We could make the types exported too as you wrote above, but the more you export the more likelihood there will be a naming conflict, and we currently don't have a good way to detect and correct those. Also, this tree structure is a setup for https://github.com/hey-api/openapi-ts/issues/28. Once that is resolved, maybe we can clean it up a bit
For now then ill do my own exports export type TDataGetApiV1Foo = ReturnType<typeof DefaultService.foo>
👍
PR refactor(types): generate types for services when useOptions is true added types of the Options objects. Would be nice if these were exported as well