arrayT
On this page

arrayT()

Function in Types

Builds the ShaderType for an array.

import { arrayT } from 'typeshade'

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

Syntax

const arrayT: <E extends ShaderType, S extends number | undefined = undefined>(
elem: E,
size?: S,
) => { readonly kind: "array"; readonly elem: E; readonly size: S; }

Parameters

elem E extends ShaderType

The element type, itself a literal-typed ShaderType.

sizeoptional S extends number | undefined

The fixed element count, or undefined for a runtime-sized array.

Return value

{ readonly kind: 'array'; readonly elem: E; readonly size: S }

A { kind: 'array', elem, size } descriptor that keeps both literal types.

Description

Pass size for a fixed-length array (array<T, N>); omit it for a runtime-sized one (array<T>). Both elem and size keep their literal types so KeyOf spells the exact array<…> key that typeKey produces.

In the guide

See also

Source

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

Edit this page Report a problem