API / Core / Type

Type

Utilities for classifying the type of JavaScript values at runtime.

t

RESCRIPT
type t = [ | #bigint | #boolean | #function | #number | #object | #string | #symbol | #undefined ]

The possible types of JavaScript values.

typeof

RESCRIPT
let typeof: 'a => t

typeof(someValue)

Returns the underlying JavaScript type of any runtime value.

See typeof on MDN.

Examples

RESCRIPT
Console.log(Type.typeof("Hello")) // Logs "string" to the console. let someVariable = true switch someVariable->Type.typeof { | #boolean => Console.log("This is a bool, yay!") | _ => Console.log("Oh, not a bool sadly...") }