structT
On this page

structT()

Function in Types

Builds the ShaderType for a named struct: the type you pass wherever a struct-typed value is authored (a b.var(name, structT('VsOut')) local, an fn parameter, an array element via arrayT).

import { structT } from 'typeshade'

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

Syntax

const structT: <N extends string>(
name: N,
) => { readonly kind: "struct"; readonly name: N; }

Parameters

name N extends string

The struct’s declared name; it becomes the type’s key, struct:<name>.

Return value

{ readonly kind: 'struct'; readonly name: N }

A { kind: 'struct', name } descriptor whose name keeps its literal type.

Description

Two calls with the same name compare equal under typeKey and typeEq regardless of identity, since the key is the name string alone; the field list is never compared here. Prefer the higher-level ioStruct and uniformStruct declarators for new code, which return a typed accessor built on top of this; call structT directly when you already have a StructDecl and need its bare ShaderType.

Examples

Example

import { structT, typeEq } from 'typeshade'
// Equality is by name only.
typeEq(structT('DF64Vec2'), structT('DF64Vec2')) // true

See also

Source

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

Edit this page Report a problem