Skip to content

Commit

Permalink
[JS] Allow [<Erase>] to work on members (#3940)
Browse files Browse the repository at this point in the history
  • Loading branch information
MangelMaxime authored Oct 25, 2024
1 parent f6f33a6 commit fa17df3
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Fable.Cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [Rust] Added decision tree multiple target references (by @ncave)
* [Rust] Added Char surrogate tests for completeness (by @ncave)
* [JS] Add `System.String.Normalize` support (by @DashieTM)
* [JS] Allow `[<Erase>]` to work on members (by @MangelMaxime)

### Fixed

Expand Down
3 changes: 3 additions & 0 deletions src/Fable.Transforms/FSharp2Fable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,9 @@ let private transformMemberDecl
// Ignore members generated by the F# compiler (for comparison and equality)
elif isCompilerGenerated memb args then
[]
// Ignore members that are decorated with [<Erase>]
elif hasAttrib Atts.erase memb.Attributes then
[]
elif memb.IsOverrideOrExplicitInterfaceImplementation then
if not memb.IsCompilerGenerated then
match memb.DeclaringEntity with
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Integration/CompilationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let tests =
Directory.EnumerateDirectories(data)
|> Seq.map (fun testCaseDir -> //
testCaseAsync
(Path.GetDirectoryName(testCaseDir))
testCaseDir
(async {
let project =
Directory.GetFileSystemEntries(testCaseDir, "*.fsproj") |> Seq.exactlyOne
Expand Down
15 changes: 15 additions & 0 deletions tests/Integration/Integration/data/eraseAttribute/Members.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module EraseAttributeMembers

open Fable.Core

type input() =

[<Erase>]
member this.onChange
with set (_: obj -> unit) = ()


type input with

[<Erase>]
member this.onChange2 set (_: obj -> unit) = ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { class_type } from "./fable_modules/fable-library-js.4.22.0/Reflection.js";

export class input {
constructor() {
}
}

export function input_$reflection() {
return class_type("EraseAttributeMembers.input", undefined, input);
}

export function input_$ctor() {
return new input();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

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

</Project>

0 comments on commit fa17df3

Please sign in to comment.