yfm-docs icon indicating copy to clipboard operation
yfm-docs copied to clipboard

feat: Add generic for Run in build hooks

Open mass3ff3ct opened this issue 6 months ago • 0 comments

Проблема

На текущий момент нет возможности расширить объект 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
    }

    .....
})

mass3ff3ct avatar Jul 11 '25 23:07 mass3ff3ct