Skip to content

Type

Type holds a reference to a runtime type with an optional type-checked set of type parameters.

new Type(kindValue, parametersValue?, runtimeTypeName, isAssignableTypeFn?, isAssignableRuntimeTypeFn?, traitMaskValue?): Type

Kind

Type[] = emptyParams

string

(other) => boolean

(other) => boolean

number = 0

Type

convertToNative(_typeDesc?): never

ConvertToNative converts the Value to a native TypeScript value according to the provided type description, or throws if the conversion is not feasible.

unknown

never

Val.convertToNative


convertToType(typeValue): Val

ConvertToType supports type conversions between CEL value types supported by the expression language.

RefType

Val

Val.convertToType


declaredTypeName(): string

DeclaredTypeName indicates the fully qualified and parameterized type-check type name.

string


equal(other): Val

Equal indicates whether two types have the same runtime type name.

Val

Val

Val.equal


hasTrait(trait): boolean

HasTrait returns whether the type has a given trait associated with it.

See common/types/traits/traits.go for a list of supported traits.

number

boolean

RefType.hasTrait


isAssignableRuntimeType(val): boolean

IsAssignableRuntimeType determines whether the current type is runtime assignable from the input runtimeType.

Val

boolean


isAssignableType(fromType): boolean

IsAssignableType determines whether the current type is type-check assignable from the input fromType.

Type

boolean


isEquivalentType(other): boolean

IsEquivalentType indicates whether two types are equivalent.

Type

boolean


isExactType(other): boolean

IsExactType indicates whether the two types are exactly the same.

Type

boolean


kind(): Kind

Kind indicates general category of the type.

Kind


parameters(): Type[]

Parameters returns the list of type parameters if set.

Type[]


toString(): string

String returns a human-readable definition of the type name.

string


traitMask(): number

traitMask returns the internal trait mask for local helpers.

number


type(): RefType

Type returns the TypeValue of the value.

RefType

Val.type


typeName(): string

TypeName returns the type-erased fully qualified runtime type name.

string

RefType.typeName


value(): unknown

Value returns the raw value of the instance which may not be directly compatible with the expression language types.

unknown

Val.value


withTraits(traits): Type

WithTraits creates a copy of the current Type and sets the trait mask to the traits parameter.

number

Type