reactjs / reactjs/react.dev

[Suggestion]: Add types to React compiler debugging example

Open
#8,245 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: documentation
Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

Summary

Hello I noticed that the examples on the debugging page (https://react.dev/reference/react-compiler/logger#basic-logging) for the compiler don’t include TypeScript types. It might be helpful to add them for the basic example like so

import type { Logger } from 'babel-plugin-react-compiler';

{
...
  logger: {
    logEvent(filename, event) {
      switch (event.kind) {
        case 'CompileSuccess': {
          console.log(`✅ Compiled: ${filename}`);
          break;
        }
        case 'CompileError': {
          console.log(`❌ Skipped: ${filename}`);
          break;
        }
        default: {}
      }
    }
  } satisfies Logger,
...
}

Using satisfies Logger ensures that logEvent(filename, event) is properly typed without needing to manually annotate the parameters.

Cheers

Page

Compiler debugging docs

Details

Adding types would be helpful for IntelliSense and would also help avoid potential errors.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the React compiler debugging documentation's basic logging example linked in the issue. Update the example to demonstrate the proposed TypeScript import and Logger satisfaction, then verify that the displayed example includes typed logger events and remains consistent with the surrounding documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.