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

Combined and Omit<> types #474

Open
Wouter8 opened this issue Aug 24, 2023 · 2 comments
Open

Combined and Omit<> types #474

Wouter8 opened this issue Aug 24, 2023 · 2 comments

Comments

@Wouter8
Copy link

Wouter8 commented Aug 24, 2023

I'm wondering if combined types (using &) and Omitted fields (using Omit<> ) are supported. I understand that these features are not supported by F#, but I was hoping that this tool had a workaround for it.

I tried it in the online demo and it seems ts2fable simply doesn't even try.

Input:

type Foo = {
    field1: "value1" | "value2";
    field2: number;
}

type Combined = Foo & {
    other: string;
}

type Omitted = Omit<Foo, "value">;

Output:

// ts2fable 0.9.0
module rec moduleName
open System
open Fable.Core
open Fable.Core.JS


type [<AllowNullLiteral>] Foo =
    abstract field1: FooField1 with get, set
    abstract field2: float with get, set

type [<AllowNullLiteral>] Combined =
    interface end

type Omitted =
    Omit<Foo, string>

type [<StringEnum>] [<RequireQualifiedAccess>] FooField1 =
    | Value1
    | Value2
@Booksbaum
Copy link
Contributor

I'm wondering if combined types (using &) and Omitted fields (using Omit<> ) are supported.

Unfortunately not supported. Sorry.

In general: I think no Utility Type is currently handled (with exception of NonNullable)

@kevinbarabash
Copy link

Many of the utility types are based on mapped types and conditional types which can't really be translated into F#'s type system.

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

3 participants