From 5adbc554eae4bafa60e1b260b9f565f27c7603cf Mon Sep 17 00:00:00 2001 From: Jamie White Date: Mon, 3 Aug 2020 14:00:54 +0200 Subject: [PATCH] fix(hooks): match type of Config.runHook to IConfig.runHook --- src/config.ts | 2 +- test/typescript.test.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/config.ts b/src/config.ts index 6d6f957f..033eafa4 100644 --- a/src/config.ts +++ b/src/config.ts @@ -304,7 +304,7 @@ export class Config implements IConfig { } } - async runHook(event: string, opts: T) { + async runHook>(event: K, opts: T[K]): Promise { debug('start %s hook', event) const promises = this.plugins.map(p => { const debug = require('debug')([this.bin, p.name, 'hooks', event].join(':')) diff --git a/test/typescript.test.ts b/test/typescript.test.ts index 42883e7a..7da8eff3 100644 --- a/test/typescript.test.ts +++ b/test/typescript.test.ts @@ -46,8 +46,7 @@ describe('typescript', () => { withConfig .stdout() .it('runs init hook', async ctx => { - // to-do: fix union types - await (ctx.config.runHook as any)('init', {id: 'myid', argv: ['foo']}) + await (ctx.config.runHook)('init', {id: 'myid', argv: ['foo']}) expect(ctx.stdout).to.equal('running ts init hook\n') }) })