joi-to-typescript
joi-to-typescript copied to clipboard
Configuring converted schema to be either a type or an interface
Hi,
We are trying to solve this issue, and one way would be to use a type instead of an interface when defining strict types. Is there any way to configure joi-to-typescript
to force the generation of a type
instead of an interface
?
Thanks
It might be possible try changing this line to type and see what happens https://github.com/mrjono1/joi-to-typescript/blob/master/src/parse.ts#L161
Thanks, I will try this and let you know since I moved to some other issues. From the looks of it, that would work though.
Can you please leave this open until I get back to this? Also, if that change would do it, will that be part of some update, or would there be some way to configure or "hack" it as it is from the Joi schema.
How did you go?
Hey Jono,
Sorry for the wait. So I tried this now, changed the line inside node_modules
, in parse.js
, and it "worked", so instead of interface
it replaced the text to type
, but it's not a correct type, since the type would need to be something like: type Something = {}
instead of now which is like an interface: type Something {}
.
I guess that it would need to be a bit more explicitly coded for that.
That makes sense
would you want everything to be a type
instead of an interface
or just some of them?
I guess it would be good to be configurable as an option/parameter for backwards compatibility at least. I am not sure if changing all existing interface
files to type
ones will be safe.