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

筅森魡賤 提交于 2020-12-13 03:42:04

问题


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

来源:https://stackoverflow.com/questions/64323473/typeerror-duplicate-declaration-module-build-failed-error-in-typescript-projec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!