-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Non-nullable fields are optional in TypeScript #24
Comments
This behaviour was changed by @stafyniaksacha in #19. I am currently not using Directus actively, so I can't really judge whether having relational fields marked as nullable makes sense. |
Hmm, I see. Thanks for spending time on this project even though you're not using Directus at the moment! In my opinion, if the relationship field is marked as non_nullable in the database it makes sense that the typescript type is not nullable. |
@stafyniaksacha what are your opinions on this? |
Hum, this should be a setting as of unions. |
@stafyniaksacha we're using the Directus SDK and it somehow manages to rely information on which fields are requested or not. For example:
Will have an error on the last line:
while the typing of FollowResult is Same for queries:
Gets this typing - notice that the fields that are NOT NULL in the database are required:
|
So, maybe the best thing to do would be to completely remove optional |
I just wanted to add, that for creating items, this is very counter intuitive,as the required fields are missing then |
Okay, I've reverted the changes. I am not sure though if that is exactly what you wan't, so you could test out the changes here before I release them as a new release in a few days: |
That's a lot! Going to test it in the next days! Sorry for the late reply |
This reverts commit 231b28f0afb330c71f2e06697b25d146704888f6. See maltejur/directus-extension-generate-types#24
I just upgraded the extension from 0.3.2 to 0.4.2 and realized that some of the typing errors that arose in our project were caused by non-nullable fields being changed to optional.
Before the upgrade:
authors: string & ArticlesPeople[];
And after:
authors?: (any[] & ArticlesPeople[]) | null;
We're on Directus 9.23.1
The text was updated successfully, but these errors were encountered: