---
title: "FnHandle: type in Authoring, TypeShade API reference"
description: "FnHandle, a type in Authoring. The type fn() returns: a typed, callable handle that is also a FuncDecl."
url: https://typeshade.dev/api/fnhandle/
language: en
---

# `FnHandle`

Type in Authoring

The type fn() returns: a typed, callable handle that is also a FuncDecl.

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

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

## Syntax

```ts
type FnHandle<P extends FnParamSpec, R extends string> = FuncDecl & {
  /** Typed object-param call. TypeScript checks the argument names, types and
   *  completeness. A raw number lifts to the declared parameter type, so a `u32`
   *  parameter gets a `u32` literal. A struct-handle parameter accepts a forwarded
   *  field proxy. Arguments are read-only nodes: a call only reads them, so `Let`
   *  results and expressions are accepted. */
  (args: {
    readonly [K in keyof P]:
      | ReadonlyNode<KeyOf<ParamTypeOf<P[K]>>>
      | number
      | (P[K] extends StructParamHandle ? StructArg : never);
  }): Node<R>;
  /** @deprecated Use the object-param call `foo({ a, b })`. The positional form checks
   *  neither arity nor argument types nor order at the TypeScript level, so two arguments
   *  of the same type can be swapped without an error; the object form catches all of
   *  that. A struct field proxy is accepted and unwraps to its struct-value node. */
  (...args: (NodeLike | StructArg)[]): Node<R>;
} & { readonly decl: FuncDecl };
```

## Description

The same value makes calls (`foo({ a, b })`), drops into `module({ funcs: [foo] })`, and exposes the plain declaration as `foo.decl`. Use `FnHandle<P, R>` as a type annotation when a handle built in one place crosses a module boundary as a value other code calls: the params and return key are pinned in the type, so the caller gets the same object-param checking `fn()`’s own return value gives.

## Examples

### Example

```ts
export type FilterFn = FnHandle<{ v: typeof f32T; level: typeof f32T }, 'bool'>
```

## Source

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