From 8c2bfeb6da68e5216aeee23908cecc68e92993b0 Mon Sep 17 00:00:00 2001 From: cabboose Date: Sat, 5 Jul 2025 10:05:38 +0800 Subject: [PATCH 1/3] DOCS: Doc `??=` operator. Adjust prologue docs --- src/Fable.Core/Fable.Core.JsInterop.fs | 39 +++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/Fable.Core/Fable.Core.JsInterop.fs b/src/Fable.Core/Fable.Core.JsInterop.fs index f9841984db..73149c9947 100644 --- a/src/Fable.Core/Fable.Core.JsInterop.fs +++ b/src/Fable.Core/Fable.Core.JsInterop.fs @@ -3,7 +3,18 @@ module Fable.Core.JsInterop open System open Fable.Core -/// Compiles to ?? operator in JavaScript +/// +/// Compiles to ?? nullish coalescing operator in JavaScript. +/// +/// +/// +/// expr1 ?? expr2 +/// +/// Returns expr1 if it is neither null nor undefined on runtime; otherwise, returns expr2 +/// +/// +/// JavaScript Documentation +/// [] let (??=) (nullable: 'T) (defaultValue: 'T) : 'T = nativeOnly @@ -48,20 +59,40 @@ let emitJsExpr<'T> (args: obj) (jsCode: string) : 'T = nativeOnly let emitJsStatement<'T> (args: obj) (jsCode: string) : 'T = nativeOnly /// -/// Emit a directive prologue at the top of the file (before the imports) -/// +/// Emit a directive prologue at the top of the file (before the imports). +///

/// This is useful when working with Next.js or other frameworks that require /// a specific directive at the top of the file, such as "use client" or "use server". ///
+/// +/// let x = 5 +/// emitJsTopDirectivePrologue "use server" +/// +/// Compiles to: +/// +/// "use server"; +/// export const x = 5; +/// +/// /// Directive text let emitJsTopDirectivePrologue (text: string) : unit = nativeOnly /// /// Emit a directive prologue at the calling position. -/// +///

/// This is useful when you need to emit a directive prologue for a specific part of the code, /// such as "use client" or "use server". ///
+/// +/// let x = 5 +/// emitJsDirectivePrologue "use server" +/// +/// Compiles to: +/// +/// export const x = 5; +/// "use server"; +/// +/// /// Directive text let emitJsDirectivePrologue (text: string) : unit = nativeOnly From 5d93f4b182e3f738a20eda69c20b4f9af4dfd476 Mon Sep 17 00:00:00 2001 From: cabboose Date: Sat, 5 Jul 2025 10:18:51 +0800 Subject: [PATCH 2/3] DOCS: Use instead of
--- src/Fable.Core/Fable.Core.JsInterop.fs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Fable.Core/Fable.Core.JsInterop.fs b/src/Fable.Core/Fable.Core.JsInterop.fs index 73149c9947..f708c3ec2d 100644 --- a/src/Fable.Core/Fable.Core.JsInterop.fs +++ b/src/Fable.Core/Fable.Core.JsInterop.fs @@ -59,10 +59,9 @@ let emitJsExpr<'T> (args: obj) (jsCode: string) : 'T = nativeOnly let emitJsStatement<'T> (args: obj) (jsCode: string) : 'T = nativeOnly /// -/// Emit a directive prologue at the top of the file (before the imports). -///

-/// This is useful when working with Next.js or other frameworks that require -/// a specific directive at the top of the file, such as "use client" or "use server". +/// Emit a directive prologue at the top of the file (before the imports). +/// This is useful when working with Next.js or other frameworks that require +/// a specific directive at the top of the file, such as "use client" or "use server". ///
/// /// let x = 5 @@ -78,10 +77,9 @@ let emitJsStatement<'T> (args: obj) (jsCode: string) : 'T = nativeOnly let emitJsTopDirectivePrologue (text: string) : unit = nativeOnly /// -/// Emit a directive prologue at the calling position. -///

-/// This is useful when you need to emit a directive prologue for a specific part of the code, -/// such as "use client" or "use server". +/// Emit a directive prologue at the calling position. +/// This is useful when you need to emit a directive prologue for a specific part of the code, +/// such as "use client" or "use server". ///
/// /// let x = 5 From 978b0c0d17561e40ae15c4d85e3c3cd812bde99c Mon Sep 17 00:00:00 2001 From: Mangel Maxime Date: Wed, 21 Oct 2026 20:54:50 +0200 Subject: [PATCH 3/3] docs(core): fix ??= example and trim JsInterop docs --- src/Fable.Core/Fable.Core.JsInterop.fs | 33 ++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Fable.Core/Fable.Core.JsInterop.fs b/src/Fable.Core/Fable.Core.JsInterop.fs index f708c3ec2d..ded58d88e0 100644 --- a/src/Fable.Core/Fable.Core.JsInterop.fs +++ b/src/Fable.Core/Fable.Core.JsInterop.fs @@ -4,16 +4,22 @@ open System open Fable.Core /// -/// Compiles to ?? nullish coalescing operator in JavaScript. +/// Compiles to the JavaScript nullish coalescing operator ??. +/// Returns when it is neither null nor undefined at runtime, +/// otherwise . /// -/// -/// -/// expr1 ?? expr2 +/// +/// let name = maybeName ??= "anonymous" /// -/// Returns expr1 if it is neither null nor undefined on runtime; otherwise, returns expr2 -/// +/// Compiles to: +/// +/// const name = maybeName ?? "anonymous"; +/// +/// +/// Value tested for null or undefined. +/// Value returned when is null or undefined. /// -/// JavaScript Documentation +/// MDN: Nullish coalescing operator /// [] let (??=) (nullable: 'T) (defaultValue: 'T) : 'T = nativeOnly @@ -59,9 +65,8 @@ let emitJsExpr<'T> (args: obj) (jsCode: string) : 'T = nativeOnly let emitJsStatement<'T> (args: obj) (jsCode: string) : 'T = nativeOnly /// -/// Emit a directive prologue at the top of the file (before the imports). -/// This is useful when working with Next.js or other frameworks that require -/// a specific directive at the top of the file, such as "use client" or "use server". +/// Emits a directive prologue at the top of the file, before the imports. +/// Frameworks such as Next.js require directives like "use client" or "use server" there. /// /// /// let x = 5 @@ -73,13 +78,11 @@ let emitJsStatement<'T> (args: obj) (jsCode: string) : 'T = nativeOnly /// export const x = 5; /// /// -/// Directive text +/// Directive text. The quotes are added. let emitJsTopDirectivePrologue (text: string) : unit = nativeOnly /// -/// Emit a directive prologue at the calling position. -/// This is useful when you need to emit a directive prologue for a specific part of the code, -/// such as "use client" or "use server". +/// Emits a directive prologue at the calling position. /// /// /// let x = 5 @@ -91,7 +94,7 @@ let emitJsTopDirectivePrologue (text: string) : unit = nativeOnly /// "use server"; /// /// -/// Directive text +/// Directive text. The quotes are added. let emitJsDirectivePrologue (text: string) : unit = nativeOnly /// Create a literal JS object from a collection of key-value tuples.