[Suggestion]: Add types to React compiler debugging example
Nobody has claimed this yet.
- 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
Details
Adding types would be helpful for IntelliSense and would also help avoid potential errors.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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