I want to use an enum in my app :
export const enum typeEnum {
TVY = 'TVY',
USER = 'USER',
}
At npm run webpack:build, I get the following error :
12:111 error 'typeEnum' is already declared in the upper scope no-shadow
I read on several link relative to this error that the solution was to add the following to the eslint rules :
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error"
This is what I did, in the .eslintrc.json file :
{
"plugins": ["@typescript-eslint/tslint"],
"extends": ["jhipster"],
"parserOptions": {
"project": "./tsconfig.base.json"
},
"rules": {
"@typescript-eslint/tslint/config": [
"error",
{
"lintFile": "./tslint.json"
}
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": false
}
],
"@typescript-eslint/no-non-null-assertion": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error"
}
}
But now, I get this error also at npm run:webpack:build :
myPath\src\main\webapp\app\vendor.ts [INFO] 1:1 error Definition for rule '@typescript-eslint/no-shadow' was not found @typescript-eslint/no-shadow
Do you know what I can do?
Thanks,
Manuela
Turns out that you need to turn off the standard eslint rule, and instead use a TypeScript-specific value.
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
(I just ran into this problem, made this change, and it solved it for me)
The error basically means you have another enum with the same name somewhere on level higher (probably in global scope). Try to rename your enum and look.
BTW. Switching off rules is a bad practice. TS/ES linters say where your code have problems. In most cases you have to fix the problem in the code instead of just shut up the linter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With