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)";'