(_: A): AFunction-type alias encoding invariant variance for a phantom type parameter.
When to use
Use as a phantom field type to make a type parameter invariant, neither covariant nor contravariant.
Details
A value of type Invariant<A> cannot be assigned to Invariant<B> unless
A and B are the same type.
Example (Defining an invariant phantom type)
import type { Types } from "effect"
interface Container<T> {
readonly _phantom: Types.Invariant<T>
readonly value: T
}export type type Invariant<A> = (_: A) => AFunction-type alias encoding invariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter invariant, neither
covariant nor contravariant.
Details
A value of type Invariant<A> cannot be assigned to Invariant<B> unless
A and B are the same type.
Example (Defining an invariant phantom type)
import type { Types } from "effect"
interface Container<T> {
readonly _phantom: Types.Invariant<T>
readonly value: T
}
Namespace for
Invariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Invariant.
Invariant<function (type parameter) A in type Invariant<A>A> = (_: A_: function (type parameter) A in type Invariant<A>A) => function (type parameter) A in type Invariant<A>A
/**
* Namespace for {@link Invariant}-related utilities.
*
* **When to use**
*
* Use when referring to type-level helpers nested under `Invariant`.
*
* @since 3.9.0
*/
export declare namespace Invariant {
/**
* Extracts the type parameter `A` from an `Invariant<A>`.
*
* **When to use**
*
* Use to recover the carried type from an invariant phantom marker.
*
* **Example** (Extracting the inner type)
*
* ```ts
* import type { Types } from "effect"
*
* type Inner = Types.Invariant.Type<Types.Invariant<number>>
* // number
* ```
*
* @see {@link Invariant}
*
* @category models
* @since 3.9.0
*/
export type type Invariant<A>.Type<A> = A extends Invariant<infer U> ? U : neverExtracts the type parameter A from an Invariant<A>.
When to use
Use to recover the carried type from an invariant phantom marker.
Example (Extracting the inner type)
import type { Types } from "effect"
type Inner = Types.Invariant.Type<Types.Invariant<number>>
// number
Type<function (type parameter) A in type Invariant<A>.Type<A>A> = function (type parameter) A in type Invariant<A>.Type<A>A extends type Invariant<A> = (_: A) => AFunction-type alias encoding invariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter invariant, neither
covariant nor contravariant.
Details
A value of type Invariant<A> cannot be assigned to Invariant<B> unless
A and B are the same type.
Example (Defining an invariant phantom type)
import type { Types } from "effect"
interface Container<T> {
readonly _phantom: Types.Invariant<T>
readonly value: T
}
Namespace for
Invariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Invariant.
Invariant<infer function (type parameter) UU> ? function (type parameter) UU : never
}