---
title: "typeLayout(): function in Reflection, TypeShade API"
description: "typeLayout, a function in Reflection. Size + alignment (bytes) of a host-shareable type under a layout."
url: https://typeshade.dev/api/typelayout/
language: en
---

# `typeLayout()`

Function in Reflection

Size + alignment (bytes) of a host-shareable type under a layout.

`import { typeLayout } from 'typeshade'`

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

## Syntax

```ts
function typeLayout(
  t: ShaderType,
  layout: LayoutKind,
  structs: ReadonlyMap<string, StructDecl>,
): { size: number; align: number }
```

## Parameters

**`t` `ShaderType`**

**`layout` `LayoutKind`**

**`structs` `ReadonlyMap<string, StructDecl>`**

## Return value

`{ size: number; align: number }`

## Description

Throws on a non-host-shareable type (texture/sampler/void are bind resources, not struct fields).

Exported for `passes/uniform-layout.ts` (§51), which computes the layout of a struct as emitted — after it has inserted the wrapper structs a uniform array’s 16-byte element stride needs — and so owns its own struct and array recursion. Its leaves are these: the scalar, vector and matrix numbers are the same rule read from the same place, and a second copy of the matrix arm is exactly what’s measurement would have drifted against. `'std430'` is WGSL’s own layout; the uniform address space’s extra element rule is what that pass adds on top.

## Source

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