yfm-docs
yfm-docs copied to clipboard
feat: Add generic for Run in build hooks
Проблема
На текущий момент нет возможности расширить объект run при использовании билд хуков getBuildHooks
Решение
В getBuildHooks добавить generic тип, способный расширить объект run, по примеру с getBaseHooks
пример:
import type {Run as BaseRun} from '@diplodoc/cli/lib/run'
import type {BaseConfig} from '@diplodoc/cli/lib/program'
type MyConfig = BaseConfig & {prop: string}
type Run = BaseRun<MyConfig>
.....
getBuildHooks<Run>(program).BeforeRun.for('html').tap('Name', (run) => {
if (!run.config.prop) { // No ts error
return
}
.....
})