From f1758bac4a0db868d43b3c05690a2153233da7ca Mon Sep 17 00:00:00 2001 From: cabboose Date: Sat, 5 Jul 2025 10:05:38 +0800 Subject: [PATCH 1/2] 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 1e198a328989652a66abe72e3c527249165723ea Mon Sep 17 00:00:00 2001 From: cabboose Date: Sat, 5 Jul 2025 10:18:51 +0800 Subject: [PATCH 2/2] 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