core icon indicating copy to clipboard operation
core copied to clipboard

Need help creating a proxy for `Pluralize.NET.Core`

Open MangelMaxime opened this issue 4 months ago • 1 comments

Hello,

In our project with are using Pluralize.NET.Core (backend) and pluralize (frontend).

How can we create a Proxy in order to map the .NET API to the one from the NPM package?

My trouble right now is the .NET API use a constructor call where the NPM package expect use to call pluralize.plural directly?

module PluralizeJs =

    [<Import("pluralize")>]
    type Pluralize() =

        static member plural(s : string) = X<string>

[<Proxy(typeof<Pluralizer>)>]
type internal PluralizerProxy() =

    static member Pluralize(s : string) = PluralizeJs.Pluralize.plural(s)

let private jsPlural (s:string) = Pluralizer().Pluralize(s)
let test = Pluralizer().Pluralize("cat")

Currently generates

Pluralizer.Pluralize(new Pluralizer(), "cat");

Should generates something like

import pluralize from "pluralize"
pluralize.plural("cat")

Is there any good resource on how to create binding, proxy for WebSharper ?

MangelMaxime avatar Jul 17 '25 20:07 MangelMaxime