<A>(): <B extends A>(b: B) => BEnsures that the type of an expression matches some type, without changing the resulting type of that expression.
When to use
Use to check assignability while preserving the expression's precise inferred type.
Example (Checking an expression against a type)
import { Function } from "effect"
import * as assert from "node:assert"
const test1 = Function.satisfies<number>()(5 as const)
// ^? const test: 5
// @ts-expect-error
const test2 = Function.satisfies<string>()(5)
// ^? Argument of type 'number' is not assignable to parameter of type 'string'
assert.deepStrictEqual(Function.satisfies<number>()(5), 5)utility typescast
Source effect/Function.ts:2791 lines
export const const satisfies: <A>() => <B extends A>(
b: B
) => B
Ensures that the type of an expression matches some type,
without changing the resulting type of that expression.
When to use
Use to check assignability while preserving the expression's precise inferred
type.
Example (Checking an expression against a type)
import { Function } from "effect"
import * as assert from "node:assert"
const test1 = Function.satisfies<number>()(5 as const)
// ^? const test: 5
//
satisfies = <function (type parameter) A in <A>(): <B extends A>(b: B) => BA>() => <function (type parameter) B in <B extends A>(b: B): BB extends function (type parameter) A in <A>(): <B extends A>(b: B) => BA>(b: B extends Ab: function (type parameter) B in <B extends A>(b: B): BB) => b: B extends Ab