---
title: "isScalar(): function in Types, TypeShade API reference"
description: "isScalar, a function in Types. Narrows a ShaderType to the native { kind: 'scalar' } arm."
url: https://typeshade.dev/api/isscalar/
language: en
---

# `isScalar()`

Function in Types

Narrows a ShaderType to the native { kind: 'scalar' } arm.

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

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

## Syntax

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

## Parameters

**`t` `ShaderType`**

## Return value

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

## Description

Narrows a `ShaderType` to the native `{ kind: 'scalar' }` arm (`f32`, `i32`, `u32`, `bool`). It is `false` for [`f64T`](https://typeshade.dev/api/f64t/), which is its own kind so that this predicate does not treat it as a scalar. Arithmetic type resolution uses it to detect the vector-scalar broadcast case (`isVec(a) && isScalar(b)` and its mirror), where the vector operand’s type is the result.

## Examples

### Example

```ts
import { isScalar } from 'typeshade'
import { f32T, f64T } from 'typeshade/core/ir'

isScalar(f32T) // true
isScalar(f64T) // false: f64 is its own ShaderType kind
```

## See also

- [`f64T`](https://typeshade.dev/api/f64t/)

## Source

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