Skip to main content

generateNeverTypeCheck()

generateNeverTypeCheck(_varName, ctx, customMessage?): CodeGenResult

Experimental

Generates the type check code for a never type. Never type rejects all values - nothing can satisfy it.


Parametersโ€‹

_varName: stringโ€‹

The variable name (unused, never always fails)

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 = generateNeverTypeCheck("value", ctx);
// result.code = 'return "No value can satisfy never type";'