generateArrayTypeCheck()
generateArrayTypeCheck(
varName,ctx,customMessage?):CodeGenResult
Experimental
Generates the type check code for an array value.
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 = generateArrayTypeCheck("value", ctx);
// result.code = 'if (!Array.isArray(value)) return "Expected array";'