Tuesday 16 May 2017

typescript extend class with imported class

If I extend a locally exported class, it works.

Working example:

export class classA {

    constructor() {
        super();
    }
}

export class classB extends classA {

constructor() {
    super();

    this.do();
}

private do(): void {
    // do something
}

But when I import classA from outside of the file it's not work.

not Working example:

import { classA } from '../';
export class classB extends classA {

constructor() {
    super();

    this.do();
}

private do(): void {
    // do something
}

I need to load outside from this file, because I would like to use classA in other files... Any idea why happen this?



via Twois

No comments:

Post a Comment