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