Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Fable.Transforms/FSharp2Fable.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1825,8 +1825,7 @@ module Util =
open TypeHelpers
open Identifiers

let isUnitArg (ident: Fable.Ident) =
ident.IsCompilerGenerated && ident.Type = Fable.Unit
let isUnitArg (ident: Fable.Ident) = ident.Type = Fable.Unit
// && (ident.DisplayName.StartsWith("unitVar") || ident.DisplayName.Contains("@"))

let discardUnitArg (args: Fable.Ident list) =
Expand Down
16 changes: 10 additions & 6 deletions src/Fable.Transforms/Fable2Babel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2986,13 +2986,17 @@ but thanks to the optimisation done below we get

| _ -> transformDecisionTreeWithExtraSwitch com ctx returnStrategy targets treeExpr

let transformIdent (com: IBabelCompiler) ctx id =
let e = identAsExpr id
let transformIdent (com: IBabelCompiler) ctx (id: Fable.Ident) =
match id.Type with
// Remove unit idents, because the declaration may have been erased #4041
| Fable.Unit -> undefined id.Range None
| _ ->
let e = identAsExpr id

if com.IsTypeScript && ctx.ForcedIdents.Contains id.Name then
Expression.unaryExpression (UnaryNot, e, isSuffix = true)
else
e
if com.IsTypeScript && ctx.ForcedIdents.Contains id.Name then
Expression.unaryExpression (UnaryNot, e, isSuffix = true)
else
e

let rec transformAsExpr (com: IBabelCompiler) ctx (expr: Fable.Expr) : Expression =
match expr with
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module RemoveUnitIdents

type Model = unit

let update (model: Model) =
model, ()

update () |> ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

export function update() {
return [undefined, undefined];
}

update();

17 changes: 17 additions & 0 deletions tests/Integration/Integration/data/transforms/transforms.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RollForward>Major</RollForward>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="RemoveUnitIdents.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fable.Core" Version="4.2.0" />
</ItemGroup>

</Project>
Loading