---
title: "arrayT(): function in Types, TypeShade API reference"
description: "arrayT, a function in Types. Builds the ShaderType for an array. The type keys and type descriptors the authoring surface is typed by."
url: https://typeshade.dev/api/arrayt/
language: en
---

# `arrayT()`

Function in Types

Builds the ShaderType for an array.

`import { arrayT } from 'typeshade/core/ir'`

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

## Syntax

```ts
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`.

**`size` optional `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`](https://typeshade.dev/api/keyof/) spells the exact `array<…>` key that [`typeKey`](https://typeshade.dev/api/typekey/) produces.

## See also

- [`KeyOf`](https://typeshade.dev/api/keyof/)
- [`typeKey`](https://typeshade.dev/api/typekey/)

## Source

[`src/core/ir/types/composite-types.ts`, line 42](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/types/composite-types.ts#L42), at commit af54ddad5
