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'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
function externFn<P extends ParamSpec, R extends ShaderType>( name: string, params: P, ret: R,): ExternFn<P, R>Parameters
namestringthe callee’s emitted name, which the linked-in definition must match.
paramsP extends ParamSpecthe parameter record, in declaration order.
retR extends ShaderTypethe return type.
Return value
ExternFn<P, R>
a callable handle carrying only the signature.
Description
Prefer a
real fn() and its 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
import { externFn, f32T, vec2fT } from 'typeshade'
// 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)In the guide
See also
Source
src/core/ir/builder.ts, line 1078, at commit 26de7be8