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

fix: if field is a list custom type should also be #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chikof
Copy link

@chikof chikof commented Apr 28, 2024

If your field is an array but your custom type is not, drizzle will think that the data you have to enter to create a new entry has to be one instead of a list.

@fdarian
Copy link
Owner

fdarian commented Apr 28, 2024

I believe that the .$type<TType>() helper should allow such mistakes, as the specified TType should serve as the absolute definition for the type. Magically overriding the type could lead to unintended behavior. For instance, defining drizzle.type mod::List[] would lead to .$type<List[][]>.

However as I tested with [], it fails. The fix I think would be to sanitize the type before defining the import.

Ideally, the API should be modified in the future to separate the import and usage. This way, composing and inferring types would not result in errors. For instance, drizzle.type module::Array<Item> and drizzle.type module::Item['one'] aren't supported at the moment.

@chikof
Copy link
Author

chikof commented Apr 29, 2024

I also tried with [] haha. Instead of doing it as you showed above drizzle.type module::Array<Item>. I was thinking of just sanitizing the type, as you said, and validate if they tried to import an Array drizzle.type module::Item[].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants