typeEq
On this page

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'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

function typeEq(a: ShaderType, b: ShaderType): boolean

Parameters

a ShaderType

The first type.

b ShaderType

The second type.

Return value

boolean

true when both spell the same key.

Exceptions

SD0002

This 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, boolT } from 'typeshade'
typeEq(boolT, { kind: 'scalar', scalar: 'bool' }) // true: same key, different object

See also

Source

src/core/ir/types.ts, line 1051, at commit 26de7be8

Edit this page Report a problem