From 24419b28e3a447bcaaa99c532fc8eaacef92c84b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 09:33:30 +0000 Subject: [PATCH] Add JS Pojo documentation Agent-Logs-Url: https://github.com/goswinr/fable-compiler.github.io/sessions/503643fb-da74-4411-b4e6-797450c8df20 Co-authored-by: goswinr <884885+goswinr@users.noreply.github.com> --- docs/docs/javascript/features.md | 47 ++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/docs/docs/javascript/features.md b/docs/docs/javascript/features.md index f7b8b08..d9b73b3 100644 --- a/docs/docs/javascript/features.md +++ b/docs/docs/javascript/features.md @@ -687,7 +687,9 @@ export const user = { Fable offers several ways to work with POJOs. -The recommended way to work with POJOs is to use `[]` as they are the closest to normal F# classes. But we will explore all the potential options, from the simplest to the more verbose. +The recommended way to work with POJOs is to use `[]` when you can target Fable 5 or newer. For older Fable versions, or for methods where only some arguments should be grouped into an options object, use `[]`. + +We will explore all the potential options, from the simplest to the more verbose. ### Anonymous records @@ -792,13 +794,54 @@ export const user = { }; ``` +### `[]` + +

+ Added in v5.0.0 +

+ +`JS.Pojo` is the simplest way to write class-based POJO bindings when targeting Fable 5 or newer. + +It lets you define an F# class that is created as a plain JavaScript object, without combining `[]`, `[]` and `[]`. + +```fs +open Fable.Core + +[] +[] +type Options + ( + searchTerm: string, + ?isCaseSensitive: bool + ) = + member val searchTerm: string = jsNative with get, set + member val isCaseSensitive: bool option = jsNative with get, set + +let options1 = new Options("foo") + +let options2 = new Options("foo", isCaseSensitive = true) +``` + +generates + +```js +export const options1 = { + searchTerm: "foo", +}; + +export const options2 = { + searchTerm: "foo", + isCaseSensitive: true, +}; +``` + ### `[]`

Added in v3.4.0

-`ParamObject` allows the most native F# experience when working with POJOs. +`ParamObject` allows a native F# experience when working with POJOs, and is the pre-Fable 5 way to define class-based POJO bindings. It also has the benefit of supporting other ways of creating POJOs, allowing consumer of your code to use the method they prefer.