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

[JS] Allow [<Erase>] to work on members #3940

Merged
merged 2 commits into from
Oct 25, 2024
Merged
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
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>
Loading