Skip to content

error TS4020: 'extends' clause of exported class 'SampleNewClass' has or is using private name 'SampleMixin' #15870

@khusamov

Description

@khusamov

TypeScript Version: 2.3.2

Code

File SampleMixin.ts with mixin class:

export type Constructor<T = object> = new(...args: any[]) => T;

export interface SampleMixin {
    pluginManager: string[];
}

export default <S extends Constructor>(Superclass: S): Constructor<SampleMixin> & S => class extends Superclass {
    
    private _pluginManager: string[];
    
    get pluginManager(): string[] {
		return this._pluginManager ? this._pluginManager : this._pluginManager = [];
	}
	
}

The file index.ts where this mixin is used:

import SampleMixin from './SampleMixin';

class SampleSuperClass {}

export default class SampleNewClass extends SampleMixin(SampleSuperClass) {}

Expected behavior:

Compilation complete. Watching for file changes.

Actual behavior:

index.ts(6,22): error TS4093: 'extends' clause of exported class 'SampleNewClass' refers to a type whose name cannot be referenced.
index.ts(6,45): error TS4020: 'extends' clause of exported class 'SampleNewClass' has or is using private name 'SampleMixin'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions