Skip to content

Clean up/optimize @return(undefined_to_opt) etc. #7428

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

Open
cknitt opened this issue May 5, 2025 · 1 comment
Open

Clean up/optimize @return(undefined_to_opt) etc. #7428

cknitt opened this issue May 5, 2025 · 1 comment
Labels
Milestone

Comments

@cknitt
Copy link
Member

cknitt commented May 5, 2025

We currently have the following special directives for external function definitions:

@return(nullable)
external someFunc1: unit => option<string> = "someFunc"

@return(null_undefined_to_opt)
external someFunc2: unit => option<string> = "someFunc"

@return(undefined_to_opt)
external someFunc3: unit => option<string> = "someFunc"

@return(null_to_opt)
external someFunc4: unit => option<string> = "someFunc"
  • 1 and 2 are actually the same.
  • For 2, 3, and 4, the naming is unidiomatic (no camelCase, ...).
  • 3 is probably not needed anymore as one could just define the external to return an option?
  • Only 1 is actually documented.
@cknitt cknitt changed the title @return(undefined_to_opt) etc. Remove @return(undefined_to_opt) etc.? May 5, 2025
@cknitt cknitt added this to the v12 milestone May 5, 2025
@cknitt cknitt added the cleanup label May 6, 2025
@cknitt
Copy link
Member Author

cknitt commented May 6, 2025

Actually @return(undefined_to_opt) is useful to ensure nested options work correctly, see also the discussion in #7054 and #7430.

It is currently used in Js.Array(2) for example.

@cknitt cknitt changed the title Remove @return(undefined_to_opt) etc.? Clean up/optimize @return(undefined_to_opt) etc. May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant