error: 'xxx' is already defined (no-redeclare) when using typescript declaration merging
See original GitHub issueTell us about your environment
i am using vue-cli-plugin-electron-builder to build and bundle my electron app.
- ESLint Version: 5.16.0
- Node Version: 12.4.0
- npm Version: 6.9.0 ( actually i use
yarn 1.19.1
to manage my packages)
What parser (default, Babel-ESLint, etc.) are you using?
->
means depends on
, i will use ->
to describe dependency chain
@vue/cli-plugin-eslint 4.0.5
depends on eslint-loader 2.2.1
eslint-loader 2.2.1
invokes eslint, if i understand correctly.
Please show your full configuration:
Configuration
module.exports = {
root: true,
env: {
node: true,
},
extends: ['plugin:vue/essential', '@vue/prettier', '@vue/typescript'],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
},
parserOptions: {
parser: '@typescript-eslint/parser',
},
overrides: [
{
files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
env: {
jest: true,
},
},
],
};
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
import os from 'os';
export class NetExtra {
static ipAddresses(
family: NetExtra.IPAddressFamily = NetExtra.IPAddressFamily.ALL,
includeInternal: boolean = true
): string[] {
let ipAddresses: string[] = [];
var ifaces = os.networkInterfaces();
Object.keys(ifaces).forEach(function(ifname) {
ifaces[ifname].forEach(function(iface) {
if (!includeInternal && iface.internal !== false) {
//skip over internal (i.e. 127.0.0.1)
return;
}
if (family !== NetExtra.IPAddressFamily.ALL && iface.family != family) {
return;
}
ipAddresses.push(iface.address);
});
});
return ipAddresses;
}
}
export namespace NetExtra {
export enum IPAddressFamily {
IPV4 = 'IPv4',
IPV6 = 'IPv6',
ALL = 'all',
}
}
yarn electron:build --debug
What did you expect to happen?
eslint recognize typescript declaration merging and throw no error.
What actually happened? Please include the actual, raw output from ESLint.
error in ./src/commons/node/netExtra.ts
Module Error (from D:/Home/icenter-next/node_modules/eslint-loader/index.js): error: ‘NetExtra’ is already defined (no-redeclare) at src\commons\node\netExtra.ts:27:18: 25 | } 26 |
27 | export namespace NetExtra { | ^ 28 | export enum IPAddressFamily { 29 | IPV4 = ‘IPv4’, 30 | IPV6 = ‘IPv6’,
1 error found.
Are you willing to submit a pull request to fix this bug?
possibly not due to not knowing eslint
’s source codes and how it works
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Hi @bruceauyeung, thanks for the bug report!
I’m not sure if it’s possible to work around this issue in the core
no-redeclare
rule.It might be good to open an issue in the typescript-eslint repo, maybe they’ll have some advice. It looks similar to typescript-eslint/typescript-eslint#60
@bruceauyeung by reading typescript-eslint/typescript-eslint#60 it also seems that the same kind of warnings reported by the
no-redeclare
are already reported by the TypeScript compiler, so the solution at the moment might be to turn off the rule in the configuration if it doesn’t add value for TS projects?