eslint-plugin-react: [Bug]: `@typescript-eslint` v6 throws deprecation warnings
Is there an existing issue for this?
- I have searched the existing issues and my issue is unique
- My issue appears in the command-line and not only in the text editor
Description Overview
Using @typescript-eslint/parser 6.x throws a warning on the command line saying DeprecationWarning: The 'typeParameters' property is deprecated on CallExpression nodes. Use 'typeArguments' instead.
My project is an ejected CRA config; this prints out on the command line every time that I run eslint src on my project after I upgraded my @typescript-eslint dependencies to use the latest v6.
See https://typescript-eslint.io/linting/troubleshooting/#the-key-property-is-deprecated-on-type-nodes-use-key-instead-warnings for more info.
Expected Behavior
A warning should not be printed for deprecations.
eslint-plugin-react version
v7.32.2
eslint version
v8.45.0
node version
v18.16.1
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 15
- Comments: 15 (6 by maintainers)
It’s fine to do such patching temporarily to test out a PR you want to make, to be clear, just don’t commit or deploy it or anything 😛
I’m just a maintainer on typescript-eslint, not eslint-plugin-react, but: please don’t monkey patch modules if it’s not absolutely necessary. You never know when those patches break downstream tools or are themselves broken by package updates. Especially when there’s a recommended workaround in the thread (https://github.com/jsx-eslint/eslint-plugin-react/issues/3602#issuecomment-1641078594). I can’t guarantee that we won’t frequently break the patch by refactors on our end.
@Haprog if the
node.typeArguments || node.typeParametersswitch is presenting issues, I’d love to see specifics. We can always update https://typescript-eslint.io/blog/announcing-typescript-eslint-v6 and/or the deprecation notice with tailored instructions.Edit: what ljharb said 👇 😄
eye twitches
@JoshuaKGoldberg btw related to the instruction here https://typescript-eslint.io/linting/troubleshooting/#the-key-property-is-deprecated-on-type-nodes-use-key-instead-warnings
This was not very helpful even though I was only using about 5 plugins since disabling a plugin you also need to remove or comment out the rules related to that plugin and also need to remove related “eslint-disable <rule>” comments in your code to be able to run without errors (otherwise you’ll get errors about missing rule definitions).
I found a much easier way to figure out which plugin is causing issues is to run with Node’s
--trace-deprecationoption. For example since I was seeing these deprecation warnings when runningnpm testI could instead run withto get better debugging output and see which plugin/file/line is causing the issues without disabling any plugins/rules.
This will give output like so:
@benasher44 yes! altho #3629 already exists, so instead of a new PR, please comment on that PR with a link to a branch or commit, and I’ll pull in your changes.
Yes, of course. What I meant with monkey patching in this case was that I was just locally modifying
eslint-plugin-reactpackage in my project’snode_modulesto see what it would take to fix the issue to verify the feasibility of the suggested fix before making a PR toeslint-plugin-react. So patching just for the sake of testing the idea. 🙂A PR would be great.
You may not be able to simply use
||for this in case there are valid logic paths wheretypeParametersis falsy since then it would trigger the deprecation warning. There are some places (at least inpropTypes.js) where there is logic for checking iftypeParametersexists before using it so I assume this is the case.I think doing this instead should work:
and then use
typeArgsinstead ofnode.typeParameters.Though it seems like similar handling needs to be done for usage of
node.parent.typeArgumentsandnode.superTypeArgumentsin some places.I was testing this a bit and was able to get rid of this deprecation warning by monkey patching this kind of changes in
node_modulesdirectly. If I find some time I might contribute a PR that fixes this if you think this approach is ok.Yup, it is! Replace
node.typeParameterswith(node.typeArguments ?? node.typeParameters). That’ll support both v5 and v6 of typescript-eslint.