---
title: "externFn(): function in Authoring, TypeShade API reference"
description: "externFn, a function in Authoring. Forward-declare a callable whose real definition (fn(...)) is authored somewhere else…"
url: https://typeshade.dev/api/externfn/
language: en
---

# `externFn()`

Function in Authoring

Forward-declare a callable whose real definition (fn(...)) is authored somewhere else, or built later than the caller's own module-load time (see ExternFn).

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

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

## Syntax

```ts
function externFn<P extends ParamSpec, R extends ShaderType>(
  name: string,
  params: P,
  ret: R,
): ExternFn<P, R>
```

## Parameters

**`name` `string`**

the callee’s emitted name, which the linked-in definition must match.

**`params` `P extends ParamSpec`**

the parameter record, in declaration order.

**`ret` `R extends ShaderType`**

the return type.

## Return value

`ExternFn<P, R>`

a callable handle carrying only the signature.

## Description

Prefer a real `fn()` and its [`FnHandle`](https://typeshade.dev/api/fnhandle/) whenever the callee is importable at the call site. `externFn` buys a typed call for the genuine forward-reference case, at a cost: the caller has no declaration to list in `module({ funcs })`, so the host that owns the body links it in at emit.

## Examples

### Example

```ts
import { externFn, f32T, vec2fT } from 'typeshade/core/ir'

// Callable now; the real fn() body is linked in later, at emit, by the host.
export const warp = externFn('warp', { x: f32T, y: f32T, scale: f32T }, vec2fT)
```

## See also

- [`ExternFn`](https://typeshade.dev/api/externfn-type/)
- [`FnHandle`](https://typeshade.dev/api/fnhandle/)
- [`fn`](https://typeshade.dev/api/fn/)

## Source

[`src/core/ir/builder.ts`, line 863](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/builder.ts#L863), at commit af54ddad5
