case 'enabled':// case 'includeChildren':case 'log':case 'showToolbar':// case 'report':// case 'alwaysShowLabels':case 'dangerouslyForceRunInProduction': if (typeof value !== 'boolean') { errors.push(`- ${key} must be a boolean. Got "${value}"`); } else { validOptions[key] = value; } break;
errors array is pushed with some error message specific to boolean check.
case 'onCommitStart': if (typeof value !== 'function') { errors.push(`- ${key} must be a function. Got "${value}"`); } else { validOptions.onCommitStart = value as () => void; } break;case 'onCommitFinish': if (typeof value !== 'function') { errors.push(`- ${key} must be a function. Got "${value}"`); } else { validOptions.onCommitFinish = value as () => void; } break;case 'onRender': if (typeof value !== 'function') { errors.push(`- ${key} must be a function. Got "${value}"`); } else { validOptions.onRender = value as ( fiber: Fiber, renders: Array<Render>, ) => void; } break;
These checks validate that options such as onCommitStart, onCommitFinish, onRender are functions otherwise, respective errors are pushed into the array.
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.