Skip to content
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

Configuring converted schema to be either a type or an interface #307

Open
Ncifra opened this issue Mar 1, 2023 · 7 comments
Open

Configuring converted schema to be either a type or an interface #307

Ncifra opened this issue Mar 1, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@Ncifra
Copy link

Ncifra commented Mar 1, 2023

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

@mrjono1
Copy link
Owner

mrjono1 commented Mar 1, 2023

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

@Ncifra
Copy link
Author

Ncifra commented Mar 3, 2023

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.

@mrjono1
Copy link
Owner

mrjono1 commented Mar 28, 2023

How did you go?

@Ncifra
Copy link
Author

Ncifra commented Mar 28, 2023

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.

@mrjono1
Copy link
Owner

mrjono1 commented Mar 28, 2023

That makes sense

@mrjono1
Copy link
Owner

mrjono1 commented Apr 13, 2023

would you want everything to be a type instead of an interface or just some of them?

@Ncifra
Copy link
Author

Ncifra commented Apr 13, 2023

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.

@mrjono1 mrjono1 added the enhancement New feature or request label Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants