---
title: "isVec(): function in Types, TypeShade API reference"
description: "isVec, a function in Types. Narrows a ShaderType to the native { kind: 'vec' } arm, whose elem is 'f32' | 'i32' | 'u32'."
url: https://typeshade.dev/api/isvec/
language: en
---

# `isVec()`

Function in Types

Narrows a ShaderType to the native { kind: 'vec' } arm, whose elem is '`f32`' | '`i32`' | '`u32`'.

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

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

## Syntax

```ts
const isVec: (t: ShaderType) => t is Extract<ShaderType, { kind: "vec"; }>
```

## Parameters

**`t` `ShaderType`**

## Return value

`t is Extract<ShaderType, { kind: 'vec' }>`

## Description

The emulated-double vector is the separate `'vec64'` kind; test for it with [`isVec64`](https://typeshade.dev/api/isvec64/). Binary-op type resolution uses it (`isMat(a) && isVec(b)`, `isVec(a) && isScalar(b)`) to decide between a vector-scalar broadcast, a matrix-vector product and a same-kind op, and the `.x`/`.y`/`.r`/`.g` swizzle guards use it to reject a non-vector receiver.

## Examples

### Example

```ts
import { isVec } from 'typeshade'
import { vec3fT, f32T } from 'typeshade/core/ir'

isVec(vec3fT) // true
isVec(f32T) // false
```

## See also

- [`isVec64`](https://typeshade.dev/api/isvec64/)

## Source

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