how ignore typescript errors with @ts-ignore?
All answers here suggest disabling the whole eslint rule which is not very practical, a better solution will be to ignore the eslint error at that specific location like this:
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
You can stop using @ts-ignore
Or you can disable the eslint rule. Add that in your eslint config (.eslintrc
or equivalent)
...
"rules": {
"@typescript-eslint/ban-ts-ignore": "off"
}
...
EDIT: If you are using @typescript-eslint/eslint-plugin
version 2.18 or higher, the rule is called ban-ts-comment
and you need to add
"@typescript-eslint/ban-ts-comment": "off"
instead. Here is the changelog
I recommend allowing @ts-ignore
with an enforced description. This can be achieved by the following config in .eslintrc.js
. Link to documentation
rules: {
'@typescript-eslint/ban-ts-comment': [
'error',
{'ts-ignore': 'allow-with-description'},
],
},
Posting as an answer instead of comment to the accepted answer because of my lack of reputation. I still want to contribute and possibly help someone out.
The rule for me was
@typescript-eslint/ban-ts-comment
not ban-ts-ignore