typeEq()
Function in Types
Structural equality for ShaderType: two types are equal when their typeKey strings match, so a constant like boolT compares equal to a freshly built { kind: 'scalar', scalar: 'bool' } object even though they are different references.
import { typeEq } from 'typeshade'import { typeEq } from 'typeshade/core/ir'
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
function typeEq(a: ShaderType, b: ShaderType): booleanParameters
aShaderTypeThe first type.
bShaderTypeThe second type.
Return value
boolean
true when both spell the same key.
Exceptions
SD0002This is the check every binary-op, assignment and fn-argument type gate runs before raising SD0002.
Description
Structural equality for ShaderType: two types are equal when their typeKey strings
match, so a constant like boolT compares equal to a freshly built { kind: 'scalar', scalar: 'bool' } object even though they are different references. This is the check every
binary-op, assignment and fn-argument type gate runs before raising SD0002 (“type
mismatch”). Compare two ShaderTypes with this function: === compares references, and a
deep equal is slower for the same answer.
Examples
Example
import { typeEq } from 'typeshade'import { boolT } from 'typeshade/core/ir'
typeEq(boolT, { kind: 'scalar', scalar: 'bool' }) // true: same key, different objectSee also
Source
src/core/ir/types.ts, line 175, at commit af54ddad5