type Rule = readonly [string, Config]; type Config = T | Promise | ExectableConfig; type ExectableConfig = (() => T) | (() => Promise); type ExecutedRule = readonly [string, T]; export default execute; export async function execute(rule?: Rule): Promise | null> { if (!Array.isArray(rule)) { return null; } const [name, config] = rule; const fn = executable(config) ? config : async () => config; return [name, await fn()]; } function executable(config: Config): config is ExectableConfig { return typeof config === "function"; }