Skip to content

fix(eslint-plugin-react-compiler): add TypeScript type declarations#574

Open
everettbu wants to merge 2 commits into
mainfrom
fix/eslint-plugin-dts
Open

fix(eslint-plugin-react-compiler): add TypeScript type declarations#574
everettbu wants to merge 2 commits into
mainfrom
fix/eslint-plugin-dts

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of facebook/react#35856
Original author: sleitor


Summary

Add a hand-written index.d.ts to provide TypeScript types for eslint-plugin-react-compiler. This fixes the implicit any type error when importing the plugin with checkJs enabled in tsconfig.json.

The declaration file exports the three public symbols: configs, rules, and meta.

Fixes #31334

Changes

  • Added index.d.ts with type declarations for the plugin's public API
  • Added "types": "index.d.ts" to package.json
  • Added index.d.ts to files array so it's included in npm package

Add a hand-written index.d.ts to provide TypeScript types for
eslint-plugin-react-compiler. This fixes the implicit 'any' type error
when importing the plugin with checkJs enabled in tsconfig.json.

The declaration file exports the three public symbols: configs, rules,
and meta.

Closes #31334
@greptile-apps

greptile-apps Bot commented Feb 21, 2026

Copy link
Copy Markdown

Greptile Summary

Adds hand-written TypeScript type declarations (index.d.ts) for eslint-plugin-react-compiler to fix implicit any errors when importing the plugin with checkJs enabled. The package.json is updated to reference the new declaration file.

  • The exported types (meta, configs, rules) accurately reflect the runtime shape of the module's public API
  • Minor: the severity field in configs.recommended.plugins['react-compiler'].rules is typed as string rather than a narrower string literal union matching the actual ErrorSeverity enum values

Confidence Score: 4/5

  • This PR is safe to merge — it only adds a type declaration file and updates package.json metadata with no runtime changes.
  • Score of 4 reflects that the type declarations correctly match the runtime exports. The only concern is a minor loss of type precision (string vs string literal union for severity), which is a style improvement rather than a correctness issue.
  • Minor attention on compiler/packages/eslint-plugin-react-compiler/index.d.ts for the imprecise severity: string typing.

Important Files Changed

Filename Overview
compiler/packages/eslint-plugin-react-compiler/index.d.ts New hand-written TypeScript declaration file. Exports (meta, configs, rules) correctly match the runtime source. Minor: severity typed as string instead of the more precise `'Error'
compiler/packages/eslint-plugin-react-compiler/package.json Adds "types": "index.d.ts" and includes index.d.ts in the files array. Both changes are correct and necessary for distributing the type declarations.

Fix All in Claude Code Fix All in Codex

Last reviewed commit: 36045c1

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

recommended: {
plugins: {
'react-compiler': {
rules: Record<string, {rule: Rule.RuleModule; severity: string}>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity type could be more precise

The runtime type for severity is ErrorSeverity (from babel-plugin-react-compiler), which is an enum with values 'Error' | 'Warning' | 'Hint' | 'Off'. Using string here is technically correct but loses type specificity for consumers. Consider using a string literal union instead:

Suggested change
rules: Record<string, {rule: Rule.RuleModule; severity: string}>;
rules: Record<string, {rule: Rule.RuleModule; severity: 'Error' | 'Warning' | 'Hint' | 'Off'}>;

This would give consumers better autocomplete and type safety without needing to import across package boundaries.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/eslint-plugin-react-compiler/index.d.ts
Line: 18

Comment:
**Severity type could be more precise**

The runtime type for `severity` is `ErrorSeverity` (from `babel-plugin-react-compiler`), which is an enum with values `'Error' | 'Warning' | 'Hint' | 'Off'`. Using `string` here is technically correct but loses type specificity for consumers. Consider using a string literal union instead:

```suggestion
        rules: Record<string, {rule: Rule.RuleModule; severity: 'Error' | 'Warning' | 'Hint' | 'Off'}>;
```

This would give consumers better autocomplete and type safety without needing to import across package boundaries.

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants