-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bug]: TS types are broken #3838
Comments
This appears to be because only the |
Oh, that's true (though still not in line with what's actually exported). But I still can't do |
Yes, I was able to add that - even the flat config types are broken. They appear to be incompatible with ESLint's types. import type { Linter } from 'eslint';
export function reactConfig(): Linter.FlatConfig[] {
return [
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'],
];
}
On first glance, I wonder if this is because the type appears to have some recursion. It's possible to do The flat configs contain the legacy configs. Is that intentional? That might be the problem. |
@JstnMcBrd yes, that's intentional and unavoidable with the current architecture of the plugin. |
I can probably look into fixing types today or tomorrow, no promises though EDIT: so far wasn't able to |
I am having the same issue.
|
WorkaroundUse JSDoc-style type assertion to fix the types:
import react from 'eslint-plugin-react';
export const config = [
{
plugins: {
// Type assertion is workaround for incorrect TypeScript
// types in eslint-plugin-react
//
// TODO: Remove when types are fixed in eslint-plugin-react
// - https://github.com/jsx-eslint/eslint-plugin-react/issues/3838
react: /** @type {import('eslint').ESLint.Plugin} */ (react), Or, if you use
import type { ESLint } from 'eslint';
import react from 'eslint-plugin-react';
export const config = [
{
plugins: {
// Type assertion is workaround for incorrect TypeScript
// types in eslint-plugin-react
//
// TODO: Remove when types are fixed in eslint-plugin-react
// - https://github.com/jsx-eslint/eslint-plugin-react/issues/3838
react: react as ESLint.Plugin, |
Is there an existing issue for this?
Description Overview
The types as exported in #3797 and #3836 are broken and throw TS errors while used. The package only exports named namespace of
configs
, which means you can't do any of the following:https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBFApgQwMbwGZQiOByRAZwBtgA7GAWjGIFcBzcypNGPAbgChRJY4BvOKghkMwenAC+cLDnwwAnmCKoowMFSKkKHTp2FlC8QjkQBZaIgBKtYkTgBeAZK6dEAD17wAJogzJbeAMxegAKfk44KLgaBnJCAC4BBBR0KQAaSOioWyIkiOjCuAA6UpZ0YuDxQmKkYRAQRDJfb1rcwkyi6NLik0aLJBs7QiyoyU5JAEp2IA
Expected Behavior
No TS error.
eslint-plugin-react version
v7.37.1
eslint version
v8.57.0
node version
v20.9.0
typescript version
All, tested on v5.5.2, v.5.6.2
The text was updated successfully, but these errors were encountered: