diff --git a/src/Fable.Core/Fable.Core.JsInterop.fs b/src/Fable.Core/Fable.Core.JsInterop.fs index f9841984db..f708c3ec2d 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,38 @@ 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 +/// 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". +/// 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