chrisyip / koa-pug

A Pug middleware for Koa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why does `BaseContext.render` have to return `void` ?

entyo opened this issue · comments

I am trying to use koa-pug@v4.0.3 with TypeScript@^3.2
Please tell me the reason why the return type of BaseContext.render is not Promise<void> but void ? Due to the declaration merging at here,

declare module 'koa' {
  export interface BaseContext {
    render: (tpl: string, locals?: any, options?: RenderOptions, noCache?: boolean) => void
  }
}

I receive some lint violations from ESLint when I try to call render method of ctx.

ctx.status = 404;
await ctx.render('4xx.pug');

error Unexpected await of a non-Promise (non-"Thenable") value @typescript-eslint/await-thenable`

Fixed in 4.0.4.

Thank you.