DocsPlaygroundBlogCommunityPackages
  • Playground
  • Blog
  • Community
  • Packages
  • X
  • Bluesky
  • GitHub
  • Forum
Language ManualAPISyntax LookupReact
Overview
Stdlib
  • t
    timeoutId
  • v
    setTimeout
  • v
    setTimeoutFloat
  • v
    clearTimeout
  • t
    intervalId
  • v
    setInterval
  • v
    setIntervalFloat
  • v
    clearInterval
  • v
    encodeURI
  • v
    decodeURI
  • v
    encodeURIComponent
  • v
    decodeURIComponent
  • t
    date
  • t
    null
  • t
    undefined
  • t
    nullable
  • t
    lazy_t
    D
  • v
    window
    D
  • v
    document
    D
  • v
    globalThis
  • v
    import
  • v
    panic
  • v
    assertEqual
  • v
    null
  • v
    undefined
  • v
    typeof
submodules
  • Array
  • ArrayBuffer
  • AsyncIterator
  • BigInt
  • BigInt64Array
    • Constants
    BigUint64Array
    • Constants
  • Bool
  • Console
  • DataView
  • Date
    • UTC
  • Dict
  • Error
    • URIError
    • TypeError
    • SyntaxError
    • ReferenceError
    • RangeError
    • EvalError
  • Exn
  • Float
    • Constants
    Float32Array
    • Constants
    Float64Array
    • Constants
    Int
    • Ref
    • Bitwise
    • Constants
    Int16Array
    • Constants
    Int32Array
    • Constants
    Int8Array
    • Constants
  • IntervalId
  • Intl
    • Segments
    • Segmenter
    • RelativeTimeFormat
    • PluralRules
    • NumberFormat
      • Grouping
    • Locale
    • ListFormat
    • DateTimeFormat
    • Collator
    • Common
  • Iterator
  • JSON
    • Decode
    • Encode
    • Classify
    JsError
    • URIError
    • TypeError
    • SyntaxError
    • ReferenceError
    • RangeError
    • EvalError
  • JsExn
  • Lazy
  • List
  • Map
  • Math
    • Int
    • Constants
  • Null
  • Nullable
  • Object
  • Option
  • Ordering
  • Pair
  • Promise
  • RegExp
    • Result
  • Result
  • Set
  • String
  • Symbol
  • TimeoutId
  • Type
    • Classify
  • TypedArray
  • Uint16Array
    • Constants
    Uint32Array
    • Constants
    Uint8Array
    • Constants
    Uint8ClampedArray
    • Constants
  • WeakMap
  • WeakSet
  • Docs / API / Stdlib

    Stdlib

    timeoutId

    RESCRIPT
    type timeoutId = Global.timeoutId

    An id representing a timeout started via setTimeout.

    See setTimeout on MDN.

    setTimeout

    RESCRIPT
    let setTimeout: (unit => unit, int) => timeoutId

    setTimeout(callback, durationInMilliseconds) starts a timer that will execute callback after durationInMilliseconds.

    See setTimeout on MDN.

    Examples

    RESCRIPT
    // Log to the console after 200 milliseconds. let timeoutId = setTimeout(() => { Console.log("This prints in 200 ms.") }, 200)

    setTimeoutFloat

    RESCRIPT
    let setTimeoutFloat: (unit => unit, float) => timeoutId

    setTimeoutFloat(callback, durationInMilliseconds) starts a timer that will execute callback after durationInMilliseconds.

    The same as setTimeout, but allows you to pass a float instead of an int for the duration.

    See setTimeout on MDN.

    Examples

    RESCRIPT
    // Log to the console after 200 milliseconds. let timeoutId = setTimeoutFloat(() => { Console.log("This prints in 200 ms.") }, 200.)

    clearTimeout

    RESCRIPT
    let clearTimeout: timeoutId => unit

    clearTimeout(timeoutId) clears a scheduled timeout if it hasn't already executed.

    See clearTimeout on MDN.

    Examples

    RESCRIPT
    let timeoutId = setTimeout(() => { Console.log("This prints in 2 seconds.") }, 2000) // Clearing the timeout right away, before 2 seconds has passed, means that the above callback logging to the console will never run. clearTimeout(timeoutId)

    intervalId

    RESCRIPT
    type intervalId = Global.intervalId

    An id representing an interval started via setInterval.

    See setInterval on MDN.

    setInterval

    RESCRIPT
    let setInterval: (unit => unit, int) => intervalId

    setInterval(callback, intervalInMilliseconds) starts an interval that will execute callback every durationInMilliseconds milliseconds.

    See setInterval on MDN.

    Examples

    RESCRIPT
    // Log to the console ever 200 ms (200 milliseconds). let intervalId = setInterval(() => { Console.log("This prints every 200 ms.") }, 200) let timeoutId = setTimeout(() => { clearInterval(intervalId) }, 500)

    setIntervalFloat

    RESCRIPT
    let setIntervalFloat: (unit => unit, float) => intervalId

    setIntervalFloat(callback, intervalInMilliseconds) starts an interval that will execute callback every durationInMilliseconds milliseconds.

    The same as setInterval, but allows you to pass a float instead of an int for the duration.

    See setInterval on MDN.

    Examples

    RESCRIPT
    // Log to the console ever 2 seconds (200 milliseconds). let intervalId = setIntervalFloat(() => { Console.log("This prints every 200 ms") }, 200.) // Stop the interval after 500 ms let timeoutId = setTimeoutFloat(() => { clearInterval(intervalId) }, 500.0)

    clearInterval

    RESCRIPT
    let clearInterval: intervalId => unit

    clearInterval(intervalId) clears a scheduled interval.

    See clearInterval on MDN.

    Examples

    RESCRIPT
    let intervalId = setInterval(() => { Console.log("This prints in 100 ms") }, 100) // Stop the interval after 500 ms let timeoutId = setTimeout(() => { clearInterval(intervalId) }, 500)

    encodeURI

    RESCRIPT
    let encodeURI: string => string

    Encodes a URI by replacing characters in the provided string that aren't valid in a URL.

    This is intended to operate on full URIs, so it encodes fewer characters than what encodeURIComponent does. If you're looking to encode just parts of a URI, like a query parameter, prefer encodeURIComponent.

    See encodeURI on MDN.

    Examples

    RESCRIPT
    Console.log(encodeURI("https://rescript-lang.org?array=[someValue]")) // Logs "https://rescript-lang.org?array=%5BsomeValue%5D" to the console.

    decodeURI

    RESCRIPT
    let decodeURI: string => string

    Decodes a previously encoded URI back to a regular string.

    This is intended to operate on full URIs, so it decodes fewer characters than what decodeURIComponent does. If you're looking to decode just parts of a URI, like a query parameter, prefer decodeURIComponent.

    See decodeURI on MDN.

    Examples

    RESCRIPT
    Console.log(decodeURI("https://rescript-lang.org?array=%5BsomeValue%5D")) // Logs "https://rescript-lang.org?array=[someValue]" to the console.

    encodeURIComponent

    RESCRIPT
    let encodeURIComponent: string => string

    Encodes a string so it can be used as part of a URI.

    See encodeURIComponent on MDN.

    Examples

    RESCRIPT
    Console.log(encodeURIComponent("array=[someValue]")) // Logs "array%3D%5BsomeValue%5D" to the console.

    decodeURIComponent

    RESCRIPT
    let decodeURIComponent: string => string

    Decodes a previously URI encoded string back to its original form.

    See decodeURIComponent on MDN.

    Examples

    RESCRIPT
    Console.log(decodeURIComponent("array%3D%5BsomeValue%5D")) // Logs "array=[someValue]" to the console.

    date

    RESCRIPT
    type date = Date.t

    null

    RESCRIPT
    type null<'a> = null<'a>

    undefined

    RESCRIPT
    type undefined<'a> = undefined<'a>

    nullable

    RESCRIPT
    type nullable<'a> = nullable<'a>

    lazy_t

    Deprecated

    Use Lazy.t instead

    RESCRIPT
    type lazy_t<'a> = Lazy.t<'a>

    window

    Deprecated

    Use rescript-webapi instead

    RESCRIPT
    let window: Dom.window

    document

    Deprecated

    Use rescript-webapi instead

    RESCRIPT
    let document: Dom.document

    globalThis

    RESCRIPT
    let globalThis: {..}

    import

    RESCRIPT
    let import: 'a => promise<'a>

    import(value) dynamically import a value or function from a ReScript module. The import call will return a promise, resolving to the dynamically loaded value.

    Examples

    Array.res file:

    RESCRIPT
    @send external indexOf: (array<'a>, 'a) => int = "indexOf" let indexOfOpt = (arr, item) => switch arr->indexOf(item) { | -1 => None | index => Some(index) }

    In other file you can import the indexOfOpt value defined in Array.res

    RESCRIPT
    let main = async () => { let indexOfOpt = await import(Array.indexOfOpt) let index = indexOfOpt([1, 2], 2) Console.log(index) }

    Compiles to:

    JAVASCRIPT
    async function main() { var add = await import("./Array.mjs").then(function(m) { return m.indexOfOpt; }); var index = indexOfOpt([1, 2], 2); console.log(index); }

    panic

    RESCRIPT
    let panic: string => 'a

    assertEqual

    RESCRIPT
    let assertEqual: ('a, 'a) => unit

    assertEqual(a, b) check if a is equal b. If not throw a panic exception

    Examples

    RESCRIPT
    list{1, 2}->List.tailExn == list{2}

    null

    RESCRIPT
    let null: nullable<'a>

    undefined

    RESCRIPT
    let undefined: nullable<'a>

    typeof

    RESCRIPT
    let typeof: 'a => Type.t
    Types and values
    • t
      timeoutId
    • v
      setTimeout
    • v
      setTimeoutFloat
    • v
      clearTimeout
    • t
      intervalId
    • v
      setInterval
    • v
      setIntervalFloat
    • v
      clearInterval
    • v
      encodeURI
    • v
      decodeURI
    • v
      encodeURIComponent
    • v
      decodeURIComponent
    • t
      date
    • t
      null
    • t
      undefined
    • t
      nullable
    • t
      lazy_t
      D
    • v
      window
      D
    • v
      document
      D
    • v
      globalThis
    • v
      import
    • v
      panic
    • v
      assertEqual
    • v
      null
    • v
      undefined
    • v
      typeof

    © 2025 The ReScript Project

    About
    • Community
    • ReScript Association
    Find us on