ts2fable icon indicating copy to clipboard operation
ts2fable copied to clipboard

Combined and Omit<> types

Open Wouter8 opened this issue 2 years ago • 2 comments

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

Wouter8 avatar Aug 24 '23 06:08 Wouter8

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)

Booksbaum avatar Aug 28 '23 10:08 Booksbaum

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

k4b7 avatar Oct 22 '23 00:10 k4b7