TypeError: Duplicate declaration, Module build failed Error in Typescript Project

Viewed 589

Good Day,

I have code something like below

In A.ts file:

declare class LayerManager {
    //code
    constructor(factory: Factory);
    //code
}

let self: LayerManager;

function LayerManager(factory: Factory) {
   //code
   self = this;
   //code
}

export default LayerManager;

In B.ts file:

import LayerManager from '../layer-manager/index';

//Code

this.layer = new LayerManager(this.factory);  //<---In order to have construct Signature

I am using an approach Accepted on SO Link

The problem is i am getting an error of Module build fail(babel) continuously. Attaching Screenshot:

webpack:

{
                // Include ts, tsx, js, and jsx files.
                test: /\.(ts|js)x?$/,
                exclude: /node_modules/,
                loader: require.resolve('babel-loader'),
                query: { compact: true }
},

Any suggestion would be helpful.

MINIMAL Reproduction added on GITHUB

enter image description here

0 Answers
Related