-
Notifications
You must be signed in to change notification settings - Fork 21
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
Naming conflict of exported member. Cannot use the word Type
in schema.prisma
#11
Comments
If I may make a proposal. I don't think appending "Type" to the end of the exported typescript types is a good approach. In the Typebox documentation they do not do this. They simply do the following: export const A = Type.Object({
a: Type.String(),
b: Type.String(),
});
export type A = Static<typeof A>; That means the code that is generated differs from standard Typebox conventions. It also opens up the possibility of name conflicts as outlined by this issue. Because of this I personally think it's preferable to omit the "Type" suffix altogether. Alternatively, if you want to keep appending a suffix to the generated types perhaps a configuration option could be added that would allow users to edit the default suffix? So for example something like this
Could produce something like this export const A = Type.Object({
a: Type.String(),
b: Type.String(),
});
export type ABlah = Static<typeof A>; What are your thoughts @adeyahya? I'd be willing to open a PR for either of these implementations. I have a working fork now as I needed a quick fix (https://github.com/joshmossas/prisma-typebox-generator), however it also has a bunch of other changes as well that were specific to our use case so each of those will prolly need to be reviewed as well. |
Hi @joshmossas I agree with you about suffix, let's make the major release Omit the suffix by default but we still support it through config. I've been looking at your fork and I found it really good, you even make the prettier configurable, if you willing to open PR I would really happy to review and help on the documentation. |
Okay, sure! I'll prep a PR once I get home In a few hours |
I support the suffix being configurable but ideally the suffix would apply to the schema and not the type export (or in addition to). I always use |
Since I can't dedicate time to maintain this repository, I've updated the readme to refer to prismabox instead. This is because it offers better support, maintained, and has a more suitable name. |
Hi!
First of all, thanks for creating this. It's a great tool! One issue though and likely it's with my naming of things, but I want to just see if there's something here that could be improved as I didn't foresee this issue when i created my prisma schema.
I have a schema.prisma which looks partly like this:
The outputted index file from it looks like this:
This produces a problem in the outputted index.ts file like so:
![prisma-typebox-1](https://user-images.githubusercontent.com/15021423/197741535-b1650f95-365e-42ec-ba57-36cc19068b2a.jpg)
Component.ts
Because the file
Component
gets a generated type called ComponentType. This of course is something that is what it is but perhaps a thing to note in the readme (unless i missed it and it's already there).I can of course get around this with naming my enum something like ComponentEnum instead
The text was updated successfully, but these errors were encountered: