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

Consider using nullness instead of Option to map null | undefined types #121

Open
MangelMaxime opened this issue Sep 13, 2024 · 0 comments

Comments

@MangelMaxime
Copy link
Contributor

TypeScript documentation:

interface ConfigTypeMap {
        default: string | null;
    }

translates into

[<AllowNullLiteral>]
[<Interface>]
type ConfigTypeMap =
    abstract member ``default``: string | null with get, set

How should we represents optional properties and optional parameters?

interface ErrorHandling {
    error?: string | undefined | null;
}

interface PromiseLike<T> {
    a(onfulfilled?: string | undefined | null);
    b(onfulfilled?: string | undefined);
    c(onfulfilled?: string | null);
}

if we adapt todays logic it should become something like

[<AllowNullLiteral>]
[<Interface>]
type ErrorHandling =
    abstract member error: string | null with get, set

[<AllowNullLiteral>]
[<Interface>]
type PromiseLike<'T> =
    abstract member a: ?onfulfilled: string -> unit
    abstract member b: ?onfulfilled: string -> unit
    abstract member c: ?onfulfilled: string -> unit

will this still convey the correct meaning ?

We need F# 9 to land in Fable in order to support this feature.

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

No branches or pull requests

1 participant