ModuleParts
On this page

ModuleParts

Interface in Authoring

The input shape module accepts: a Partial<ModuleDecl> whose funcs also takes a key-named record as an alternative to the array, and whose uses derives structs, bindings and consts from declarator handles.

import type { ModuleParts } from 'typeshade'

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

Syntax

interface ModuleParts extends Omit<Partial<ModuleDecl>, 'funcs'> {
readonly funcs?: readonly FuncDecl[] | Readonly<Record<string, FuncDecl>>;
readonly uses?: readonly UsesHandle[];
}

Description

Prefer the record funcs form when the module’s function names are its own variable names; an anonymous fn(params, body) is named by its key, with no separate name string to keep in sync. Prefer the array form when order matters and the functions already carry explicit names.

Examples

Example

export const SPRITE_MODULE: ModuleDecl = module({
structs: [U.struct, VsOut.decl],
bindings: [U.binding, atlasTex.binding, atlasSmp.binding],
funcs: [vs, fs],
})

Instance properties

funcsoptionalread only readonly FuncDecl[] | Readonly<Record<string, FuncDecl>>

The functions, as an array in emit order or as a record whose keys name them.

usesoptionalread only readonly UsesHandle[]

Declarator handles; the module’s structs, bindings and consts are derived from them.

See also

Source

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

Edit this page Report a problem