ExternFn
On this page

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'

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

Syntax

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 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

Source

src/core/ir/builder.ts, line 1048, at commit 26de7be8

Edit this page Report a problem