hasType
hasType<
N,T>(name,tag):TypeOfNode<{name:N;type:T; }>
Defined in: src/query/expression.ts:472
The attribute is set with exactly this type, whatever its value.
Useful when the same name is written with different types across entities — a comparison already asserts the type, so this is for asking about the type alone.
Type Parameters
Section titled “Type Parameters”N extends string
T extends IndexableTypeTag
Parameters
Section titled “Parameters”N
T
The type tag: bool, i32, u64, u256, dec, str, addr or key — any
type but bytes, which is never indexed.
Returns
Section titled “Returns”TypeOfNode<{ name: N; type: T; }>
Throws
Section titled “Throws”If the name is outside the attribute name grammar.
Throws
Section titled “Throws”If the tag is not an indexable type, the name is a system
attribute (whose type is fixed), or the name starts with $ but is not a system attribute.
Example
Section titled “Example”hasType("age", "i32") // TYPEOF(age) = i32