Skip to content

Commit

Permalink
Add SerializedEvent type to JsonReporter
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]

Adds a `SerializedEvent<T>` helper type that describes how a `Logger` event of type `T` would be serialized by Metro's `JsonReporter` class.

Reviewed By: GijsWeterings

Differential Revision: D55649234

fbshipit-source-id: 757ae1d4c6f99c7e86fb92e4074e0c1d70001702
  • Loading branch information
motiz88 authored and facebook-github-bot committed Apr 5, 2024
1 parent 5730ecd commit 96e99fb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/metro/src/lib/JsonReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@

import type {Writable} from 'stream';

export type SerializedEvent<TEvent: {[string]: any, ...}> = TEvent extends {
error: Error,
...
}
? {
...Omit<TEvent, 'error'>,
message: string,
stack: string,
...
}
: TEvent;

class JsonReporter<TEvent: {[string]: any, ...}> {
_stream: Writable;

Expand Down

0 comments on commit 96e99fb

Please sign in to comment.