From 76e44c29110f12caff8302da624076b68547b8ef Mon Sep 17 00:00:00 2001 From: inottn Date: Sat, 8 Feb 2025 04:48:03 +0800 Subject: [PATCH] [compiler] Improve error messages for unhandled terminal and instruction kinds (#32324) ## Summary Improve the error message, as the value is currently an object instead of a string, which results in it being converted to '[object Object]'. ## How did you test this change? Already tested locally. --- .../src/ReactiveScopes/PrintReactiveFunction.ts | 5 ++++- .../src/TypeInference/InferTypes.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PrintReactiveFunction.ts b/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PrintReactiveFunction.ts index b5aa44ead0..259fc06486 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PrintReactiveFunction.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PrintReactiveFunction.ts @@ -394,7 +394,10 @@ function writeTerminal(writer: Writer, terminal: ReactiveTerminal): void { break; } default: - assertExhaustive(terminal, `Unhandled terminal ${terminal}`); + assertExhaustive( + terminal, + `Unhandled terminal kind \`${(terminal as any).kind}\``, + ); } } diff --git a/compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts b/compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts index 0270723c3e..44bf539e84 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts @@ -420,7 +420,10 @@ function* generateInstructionTypes( break; } default: - assertExhaustive(value, `Unhandled instruction value kind: ${value}`); + assertExhaustive( + value, + `Unhandled instruction value kind: ${(value as any).kind}`, + ); } }