koajs / discussions

KoaJS Discussions
2 stars 2 forks source link

Question on inheriting Koa #15

Open mivinci opened 4 years ago

mivinci commented 4 years ago

I wanted to inherit Koa in TypeScript to add a few properties and methods to Context because adding by using prototype does not support the auto-complete for the editor. But an error occurred when calling super.

Here's my code:

import * as Koa from "koa";

class App extends Koa {
    constructor() {
        super();
        this.use(compose([error]));
    }
}

const app = new App();

Here's the error:

 TypeError: Class constructor Application cannot be invoked without 'new'

I tried just import Application from Koa, but the same error occurred.

DelBlank commented 4 years ago

same question, solved this problem ?