---
title: "typeEq(): TypeShade 셰이더 API의 타입 분류 함수 참조 문서"
description: "typeEq, TypeShade API의 타입 분류에 속하는 함수입니다. ShaderType의 구조적 동등성 검사입니다. 두 타입은 typeKey 문자열이 일치하면 같습니다."
url: https://typeshade.dev/ko/api/typeeq/
language: ko
---

# `typeEq()`

함수, 타입 분류

ShaderType의 구조적 동등성 검사입니다. 두 타입은 typeKey 문자열이 일치하면 같습니다. 그래서 boolT 같은 상수는 참조가 달라도, 새로 만든 { kind: 'scalar', scalar: 'bool' } 객체와 같다고 판정됩니다.

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

설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.

## 구문

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

## 매개변수

**`a` `ShaderType`**

첫 번째 타입입니다.

**`b` `ShaderType`**

두 번째 타입입니다.

## 반환값

`boolean`

두 타입의 키 문자열이 같으면 `true`를 반환합니다.

## 예외

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

모든 이항 연산, 대입, fn 인자 타입 검사가 SD0002를 내기 전에 수행하는 검사입니다.

## 설명

`ShaderType`의 구조적 동등성 검사입니다. 두 타입은 [`typeKey`](https://typeshade.dev/ko/api/typekey/) 문자열이 일치하면 같습니다. 그래서 `boolT` 같은 상수는 참조가 서로 다르더라도, 새로 만든 `{ kind: 'scalar', scalar: 'bool' }` 객체와 같게 비교됩니다. 모든 이항 연산, 대입, `fn` 인자의 타입 검사는 [`SD0002`](https://typeshade.dev/ko/reference/errors/sd0002/)(“type mismatch”)를 내기 전에 이 검사를 실행합니다. 두 `ShaderType`을 비교할 때는 이 함수를 씁니다. `===`는 참조를 비교하고, 깊은 동등 비교는 같은 결과를 얻는 데 더 오래 걸립니다.

## 예제

### 예제

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

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

## 함께 보기

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

## 소스

[`src/core/ir/types.ts`, 175행](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/types.ts#L175), 커밋 af54ddad5 기준
