Skip to content

Commit f07b877

Browse files
committed
Update logger example to account for CompilerDiagnostic in CompilerError.details
`event.detail` in the logger example could either be `CompilerErrorDetail` or `CompilerDiagnostic`, yet the example only handled the simpler (but deprecated) `CompilerErrorDetail`. This adds a call to `primaryLocation` (if present) to account for the different structure of `CompilerDiagnostic` - `loc` is not present there.
1 parent a1ddcf5 commit f07b877

File tree

1 file changed

+3
-2
lines changed
  • src/content/reference/react-compiler

1 file changed

+3
-2
lines changed

src/content/reference/react-compiler/logger.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ Get specific information about compilation failures:
102102
console.error(`Details: ${event.detail.description}`);
103103
}
104104

105-
if (event.detail.loc) {
106-
const { line, column } = event.detail.loc.start;
105+
const loc = event.detail.primaryLocation?.() || event.detail.loc;
106+
if (loc) {
107+
const { line, column } = loc.start;
107108
console.error(`Location: Line ${line}, Column ${column}`);
108109
}
109110

0 commit comments

Comments
 (0)