Skip to content

Commit

Permalink
fix: if a tuple is empty generate obj (we don't have an equivalent …
Browse files Browse the repository at this point in the history
…to empty tuple in F#)

[converter]

=== changelog ===
```ts
type MyType = []
```

```fs
type MyType =
    obj
```
=== changelog ===

Fix #158
  • Loading branch information
MangelMaxime committed Dec 16, 2024
1 parent cc488b2 commit ea1c0ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Glutinum.Converter/Transform.fs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ let private transformPrimitive (gluePrimitive: GluePrimitive) : FSharpPrimitive
| GluePrimitive.Never -> FSharpPrimitive.Null

let private transformTupleType (context: TransformContext) (glueTypes: GlueType list) : FSharpType =
glueTypes |> List.map (transformType context) |> FSharpType.Tuple
match glueTypes with
| [] -> FSharpType.Object
| _ -> glueTypes |> List.map (transformType context) |> FSharpType.Tuple

module TypeLiteral =

Expand Down
1 change: 1 addition & 0 deletions tests/specs/references/literalType/emptyTuple.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type MyType = []
13 changes: 13 additions & 0 deletions tests/specs/references/literalType/emptyTuple.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module rec Glutinum

open Fable.Core
open Fable.Core.JsInterop
open System

type MyType =
obj

(***)
#r "nuget: Fable.Core"
#r "nuget: Glutinum.Types"
(***)

0 comments on commit ea1c0ce

Please sign in to comment.