TypeError: Class extends value undefined. My Class extension not working

Viewed 354

I'm trying to create a new Button class that extends from the parent Component class. Please pay attention to the very first line, namely how I import the Component class.

Button.ts:

import * as Classes from "../../classes/index";
import * as CmpInterfaces from '../../interfaces/Components/index';
import * as Types from '../../Types';

class Button extends Classes.Component implements CmpInterfaces.Button
{
    public type: Types.ButtonType = 'contained';

    /**
     * @param properties
     */
    constructor(properties: CmpInterfaces.Button) {
        super(properties);
        this.bind();
    }
}

export default Button;

The index.ts file

import * as Classes from "../../classes/index";

contains the following code:

export { default as Component } from '../../classes/Component';
export * from '../../classes/Component';

It looks good, but at compile time I get an error:

TypeError: Class extends value undefined is not a constructor or null

However, if I import the Component class directly, it doesn't throw any errors:

// import * as Classes from "../../classes/index";
import Component from '../classes/Component';

import * as CmpInterfaces from '../../interfaces/Components/index';
import * as Types from '../../Types';

// `extends Classes.Component` changed to => `extends Component`
class Button extends Component implements CmpInterfaces.Button
{
    public type: Types.ButtonType = 'contained';

    /**
     * @param properties
     */
    public constructor(properties: CmpInterfaces.Button)
    {
        super(properties);
        this.bind();
    }
}

export default Button;

I don't quite understand why this error occurs and why it doesn't work with interfaces...

0 Answers
Related