fable-compiler / Fable

F# to JavaScript, TypeScript, Python, Rust and Dart Compiler
http://fable.io/
MIT License
2.93k stars 301 forks source link

[TS] Support `[<Mangle>]` on interface #3943

Closed MangelMaxime closed 4 weeks ago

MangelMaxime commented 1 month ago

Fix #3863

@ncave I was looking into fixing #3863 and manage to fix that specific case however, if the members as an argument different than unit then it doesn't work because that member should me mangled.

The difficulty is Mangle name computation happens during FSharp2Fable transformation, but for interfaces we don't do it.

How should we approach this problem? Should we try to add Mangle information for interface too which means making a changes to Fable.AST or can we recompute the Mangle / HashSuffix using FableEntity instead of FSharpEntity?

ncave commented 4 weeks ago

@MangelMaxime Perhaps something like this? (untested, pseudo-code):

let overloadSuffix = memb.CurriedParameterGroups |> OverloadSuffix.getHash entGenParams
let memberName = memb.CompiledName + "_" + overloadSuffix

Maybe don't add suffix for getters or setters, and no "_" if suffix is empty.

MangelMaxime commented 4 weeks ago

@ncave Thank you, you allowed me to go in the right direction.

This needs a bigger rewrite than I thought at first, but it seems doable. I am working on it.