hey-api / openapi-ts

✨ Turn your OpenAPI specification into a beautiful TypeScript client

Home Page:https://heyapi.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When generated the parameter of type "object" turns into type "unknown". Type "any" would be preferred.

hugokemme7 opened this issue · comments

Description

it would be great if the type object would translate to type any instead of unknown. I cant use the type object right now, because when it transforms to unknown it gives me a ton of ts errors, wich would be solved if the type any would be used. Or maybe a way yo configure it would be nice.

Hey @hugokemme7, are you migrating from older version or different solution?

@hugokemme7 using unknown type makes more sense because the type is unknown. You could cast the resulting type to any. Is there any reason your object types are not better defined in your OpenAPI specification?

@mrlubos I am migrating to a different solution

@jordanshatford for loading data in a dropdown component we use a basic structure of {value: int, label: string}. However i now need to render a list that has the identifier of a guid instead of a int, so if i want to use the model and code behind it, i have to change value to type object.

@hugokemme7 do you mind if I ask which one and why?

@mrlubos I am sorry, I think i might have misunderstood you. I dont know if this will answer your question, but i use this library openapi-react-query-codegen. I use it to migrate my dotnet entities to tsx types. I originally placed an issue there, but he suggested i place it here, because they use this library for type specs etc.

Gotcha @hugokemme7. Are you not able to use casting to any to work around the errors?

@mrlubos yeah I could probably cast it, but it aint the cleanest solution. If there isnt a way to configure it, I will probably do that. Thanks for trying yo figure this out with me :)

There isn't at the moment, it would have to be added as an option. How much of a pain is it to use type casting?

@mrlubos it wouldnt be that much of a pain, was just more like my last resort option. Thanks for your time though.

I could add it if it was a huge dealbreaker due to migration or something like that, if you can live without it, there are other priorities :')

No, thats okay. I will try to work around it with a cast.