Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Avoid typescript-eslint deprecation warnings about typeParameters #3788

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pxpeterxu
Copy link

Motivation

When using eslint-plugin-react (7.35.0; latest) in a Typescript project with @typescript-eslint/parser": "^7.0.0", I got the following warnings when running ESLint:

# NODE_OPTIONS=--trace-deprecation yarn lint
(node:236) DeprecationWarning: The 'typeParameters' property is deprecated on CallExpression nodes. Use 'typeArguments' instead. See https://typescript-eslint.io/troubleshooting/faqs/general#the-key-property-is-deprecated-on-type-nodes-use-key-instead-warnings.
    at Object.defineProperty.get (/builds/cherrymoss/immigration/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:2545:29)
    at markAnnotatedFunctionArgumentsAsDeclared (/builds/cherrymoss/immigration/node_modules/eslint-plugin-react/lib/util/propTypes.js:1037:22)
    at /builds/cherrymoss/immigration/node_modules/eslint-plugin-react/lib/util/Components.js:281:9
    at Array.forEach (<anonymous>)
    at mergedHandler (/builds/cherrymoss/immigration/node_modules/eslint-plugin-react/lib/util/Components.js:280:16)
    at ruleErrorHandler (/builds/cherrymoss/immigration/node_modules/eslint/lib/linter/linter.js:1076:28)
    at /builds/cherrymoss/immigration/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/builds/cherrymoss/immigration/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/builds/cherrymoss/immigration/node_modules/eslint/lib/linter/node-event-generator.js:297:26)

Changes

  • Change all references to typeParameters so that they:
    1. Try looking for typeArguments first (to support @typescript-eslint/typescript-estree v7+)
    2. Fall back to typeParameters (to support @typescript-eslint/typescript-estree vv+)

Testing

Used yarn patch-package to also patch propTypes.js and verified that the deprecation errors disappeared on my project.

Copy link

codecov bot commented Jul 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.75%. Comparing base (c6fdccd) to head (7feb778).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3788   +/-   ##
=======================================
  Coverage   97.75%   97.75%           
=======================================
  Files         135      135           
  Lines        9715     9719    +4     
  Branches     3527     3530    +3     
=======================================
+ Hits         9497     9501    +4     
  Misses        218      218           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ljharb
Copy link
Member

ljharb commented Jul 22, 2024

Unfortunately we're not even testing on v6 yet, let alone v7 - see #3629, which I think this would need to be blocked on (or, that one would cover this one)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants