selectGuardedArm()
Function in Variants
Recover the arm a set of defined macros selects from an emitGuarded source.
import { selectGuardedArm } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
function selectGuardedArm(source: string, defined: Iterable<string>): string | undefinedParameters
sourcestringoutput of
VariantFamily.emitGuarded.definedIterable<string>the macro names the host would have defined.
Return value
string | undefined
the selected arm’s text, or undefined when no arm matches.
Exceptions
ErrorErrorwhen a condition insourceis not of the form the ladder generates.
Description
Understands only the ladder shape emitGuarded generates: #if, #elif and #endif at
column 0, with conditions built from defined(X) and !defined(X) joined by &&. Use it
to assert, in a test or a build step, that the arm the host’s defines select equals the
standalone variant from VariantFamily.emit, without running a compiler.
See also
Source
src/core/variant-family.ts, line 180, at commit 26de7be8