---
title: "ExternFn: type in Authoring, TypeShade API reference"
description: "ExternFn, a type in Authoring. A typed call-only handle for a function whose definition is provided elsewhere: the forward-declaration counterpart to fn()."
url: https://typeshade.dev/api/externfn-type/
language: en
---

# `ExternFn`

Type in Authoring

A typed call-only handle for a function whose definition is provided elsewhere: the forward-declaration counterpart to fn().

`import type { ExternFn } from 'typeshade'`
`import type { ExternFn } from 'typeshade/core/ir'`

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

## Syntax

```ts
type ExternFn<P extends ParamSpec, R extends ShaderType> = {
  /** Typed object-param call, with the same argument union as {@link FnHandle}: arguments
   *  are read, so read-only nodes (`Let` results, parameters) and raw numbers, lifted to the
   *  declared parameter type, are accepted. */
  (args: { readonly [K in keyof P]: ReadonlyNode<KeyOf<P[K]>> | number }): Node<KeyOf<R>>;
  /** Positional call. Arguments are matched to the parameters in declaration order. */
  (...args: NodeLike[]): Node<KeyOf<R>>;
};
```

## Description

Use it when the callee cannot be an importable [`FnHandle`](https://typeshade.dev/api/fnhandle/) at the caller’s module-load time, for instance a function a host builds from configuration after the calling module has already authored its body. The handle carries only the signature (name, parameter types and return type), so the caller makes a typed call now, object-param `f({ a, b })` or positional `f(a, b)`, and the host links the body in at emit. The emitted node is a call by name.

## See also

- [`FnHandle`](https://typeshade.dev/api/fnhandle/)

## Source

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