Skip to main content

generateVoidTypeCheck()

generateVoidTypeCheck(varName, ctx, customMessage?): CodeGenResult

Experimental

Generates the type check code for a void type. Void type only accepts undefined.


Parameters​

varName: string​

The variable name to check

ctx: GeneratorContext​

The generator context

customMessage?: string​

Optional custom error message


Returns: CodeGenResult​

Generated code and updated context


Since​

2.0.0


Example​

const result = generateVoidTypeCheck("value", ctx);
// result.code = 'if (value !== undefined) return "Expected void (undefined)";'