Skip to content

Commit 54bd672

Browse files
author
Joe Savona
committed
[compiler] Fix TS2345 error in eslint-plugin-react-hooks build
Export CompilerSuggestion type from the compiler and use it instead of `as Array<any>` in the eslint plugin's makeSuggestions(), restoring proper type narrowing for the assertExhaustive default branch.
1 parent 58400e9 commit 54bd672

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

compiler/packages/babel-plugin-react-compiler/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export {
1111
CompilerErrorDetail,
1212
CompilerDiagnostic,
1313
CompilerSuggestionOperation,
14+
type CompilerSuggestion,
1415
ErrorSeverity,
1516
ErrorCategory,
1617
LintRules,

packages/eslint-plugin-react-hooks/src/shared/ReactCompiler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import type {SourceLocation as BabelSourceLocation} from '@babel/types';
1010
import {
11+
type CompilerSuggestion,
1112
CompilerSuggestionOperation,
1213
LintRules,
1314
type LintRule,
@@ -54,7 +55,7 @@ function makeSuggestions(
5455
): Array<Rule.SuggestionReportDescriptor> {
5556
const suggest: Array<Rule.SuggestionReportDescriptor> = [];
5657
if (Array.isArray(detail.suggestions)) {
57-
for (const suggestion of detail.suggestions as Array<any>) {
58+
for (const suggestion of detail.suggestions as Array<CompilerSuggestion>) {
5859
switch (suggestion.op) {
5960
case CompilerSuggestionOperation.InsertBefore:
6061
suggest.push({

0 commit comments

Comments
 (0)