Repository: facebook/react
File: compiler/apps/playground/components/Editor/EditorImpl.tsx (TypeScript)

Code before:
            fnName: null,
            name: result.name,
            value: result.value,
          });
          break;
        }
        default: {
          const _: never = result;
          throw new Error(`Unhandled result ${result}`);
        }
      }
    };
    const parsedOptions = parseConfigPragmaForTests(pragma, {
      compilationMode: 'infer',
    });
    const opts: PluginOptions = parsePluginOptions({
      ...parsedOptions,
      environment: {
        ...parsedOptions.environment,
        customHooks: new Map([...COMMON_HOOKS]),
      },
      logger: {
        debugLogIRs: logIR,
        logEvent: (_filename: string | null, event: LoggerEvent) => {
          if (event.kind === 'CompileError') {
            error.details.push(new CompilerErrorDetail(event.detail));
          }
        },
      },
    });
    transformOutput = invokeCompiler(source, language, opts);
  } catch (err) {
    /**
     * error might be an invariant violation or other runtime error
     * (i.e. object shape that is not CompilerError)
     */
    if (err instanceof CompilerError && err.details.length > 0) {
      error.details.push(...err.details);
    } else {
      /**
       * Handle unexpected failures by logging (to get a stack trace)
       * and reporting
       */
      console.error(err);
      error.details.push(
        new CompilerErrorDetail({
          severity: ErrorSeverity.Invariant,
          reason: `Unexpected failure when transforming input! ${err}`,
          loc: null,
          suggestions: null,
        }),

Review comment (suggestion):
We might need to dedupe this, I noticed that some errors are shown twice: https://react-compiler-playground-m6niqasen-fbopensource.vercel.app/#N4Igzg9grgTgxgUxALhAejQAgAIDcCGANgJYAm+ALggHIQDKCFdFlCAkgHYAK+YYxuBAFEAZiIRwKYHCMIQA7gB0OIqB0nEIHTFDAIAYhAgAKAJSZgyzJjhawFTAG17rADSY9TFlQC6mALw6esysxo4+pgDcVpgUMACeFpgAvjFwlHAAFkmp2pgixBxEhInAKTG6wmISFMZmAQB8FjHWniFUxnFQCFExyabKySDJQA

Code after:
            kind: 'debug',
            fnName: null,
            name: result.name,
            value: result.value,
          });
          break;
        }
        default: {
          const _: never = result;
          throw new Error(`Unhandled result ${result}`);
        }
      }
    };
    const parsedOptions = parseConfigPragmaForTests(pragma, {
      compilationMode: 'infer',
    });
    const opts: PluginOptions = parsePluginOptions({
      ...parsedOptions,
      environment: {
        ...parsedOptions.environment,
        customHooks: new Map([...COMMON_HOOKS]),
      },
      logger: {
        debugLogIRs: logIR,
        logEvent: (_filename: string | null, event: LoggerEvent) => {
          if (event.kind === 'CompileError') {
            otherErrors.push(new CompilerErrorDetail(event.detail));
          }
        },
      },
    });
    transformOutput = invokeCompiler(source, language, opts);
  } catch (err) {
    /**
     * error might be an invariant violation or other runtime error
     * (i.e. object shape that is not CompilerError)
     */
    if (err instanceof CompilerError && err.details.length > 0) {
      error.details.push(...err.details);
    } else {
      /**
       * Handle unexpected failures by logging (to get a stack trace)
       * and reporting
       */
      console.error(err);
      error.details.push(
        new CompilerErrorDetail({
          severity: ErrorSeverity.Invariant,
          reason: `Unexpected failure when transforming input! ${err}`,
          loc: null,
          suggestions: null,