typeKey
On this page

typeKey()

Function in Types

The runtime twin of KeyOf: turns any ShaderType value, literal or widened, into its canonical string key.

import { typeKey } from 'typeshade'
import { typeKey } from 'typeshade/core/ir'

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

Syntax

function typeKey(t: ShaderType): string

Parameters

t ShaderType

The type to spell.

Return value

string

The canonical key string.

Description

Error messages use it (SD0002, SD0004: “expected vec3, got vec4”), and typeEq compares two types by it. Every case mirrors one arm of KeyOf; if they disagree, a value type-checks at author time but throws a spurious mismatch when the authoring code runs, or the reverse.

Examples

Example

import { typeKey } from 'typeshade'
import { vec3fT, texture2dArrayfT } from 'typeshade/core/ir'
typeKey(vec3fT) // 'vec3<f32>'
typeKey(texture2dArrayfT) // 'texture_2d_array<f32>'

See also

Source

src/core/ir/types.ts, line 87, at commit af54ddad5

Edit this page Report a problem