cap-js / cds-typer

CDS type generator for JavaScript
Apache License 2.0
29 stars 10 forks source link

Fix CDS prop nullability if `@mandatory` is used #315

Closed siarhei-murkou closed 1 month ago

siarhei-murkou commented 2 months ago

Hi @daogrady 👋 ,

Since the version 8.0.2, CDS has introduced the new logic for CDS params in CDS functions/actions. Now, we have to use @mandatory annotation instead of setting not null keyword. Whereas not null is still working on CDS entity layer.. Therefore, I have added a check on @mandatory existence in order to determine if the property should/shouldn't be marked as nullable in the compiled TypeScript files.

daogrady commented 2 months ago

Hi Siarhei,

thanks for providing this addition! Looks good on first glance, but there seem to be no tests covering this new behaviour as of now. Can you please add a test checking a mandatory vs a non-mandatory field? A more approachable way of testing has been added recently, where you basically have to write consuming TS code for your generated files. Let me know when you need help writing this test.

Best, Daniel

daogrady commented 2 months ago

Also, as I have learned today, this feature may still slightly change in the near future. So let's maybe shelf this for now until we know with certainty how @mandatory and not null will turn out.

siarhei-murkou commented 1 month ago

Also, as I have learned today, this feature may still slightly change in the near future. So let's maybe shelf this for now until we know with certainty how @mandatory and not null will turn out.

Hi Daniel, sorry for late response! 😞

Okay, I see.. Lets then wait for the final decision by cds runtime team. 🙂 I suppose, right now this PR might be closed...

So far, I'm using @mandatory together with not null as a workaround.