---
title: "typeEq(): function in Types, TypeShade API reference"
description: "typeEq, a function in Types. Structural equality for ShaderType: two types are equal when their typeKey strings match…"
url: https://typeshade.dev/api/typeeq/
language: en
---

# `typeEq()`

Function in Types

Structural equality for ShaderType: two types are equal when their typeKey strings match, so a constant like boolT compares equal to a freshly built { kind: 'scalar', scalar: 'bool' } object even though they are different references.

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

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

## Syntax

```ts
function typeEq(a: ShaderType, b: ShaderType): boolean
```

## Parameters

**`a` `ShaderType`**

The first type.

**`b` `ShaderType`**

The second type.

## Return value

`boolean`

`true` when both spell the same key.

## Exceptions

**[`SD0002`](https://typeshade.dev/reference/errors/sd0002/)**

This is the check every binary-op, assignment and fn-argument type gate runs before raising SD0002.

## Description

Structural equality for `ShaderType`: two types are equal when their [`typeKey`](https://typeshade.dev/api/typekey/) strings match, so a constant like `boolT` compares equal to a freshly built `{ kind: 'scalar', scalar: 'bool' }` object even though they are different references. This is the check every binary-op, assignment and `fn`-argument type gate runs before raising [`SD0002`](https://typeshade.dev/reference/errors/sd0002/) (“type mismatch”). Compare two `ShaderType`s with this function: `===` compares references, and a deep equal is slower for the same answer.

## Examples

### Example

```ts
import { typeEq } from 'typeshade'
import { boolT } from 'typeshade/core/ir'

typeEq(boolT, { kind: 'scalar', scalar: 'bool' }) // true: same key, different object
```

## See also

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

## Source

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