Skip to content

Commit

Permalink
fix: error method not accepting error field
Browse files Browse the repository at this point in the history
  • Loading branch information
ImLunaHey committed Jan 1, 2024
1 parent c8e4e65 commit 0015d59
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,23 @@ type Literal = z.infer<typeof literalSchema>;
type Json = Literal | { [key: string]: Json } | Json[];

type MetaForSchema<Schema extends BaseSchema, Level extends keyof Schema, Message> = [Message] extends [never]
? z.input<z.ZodType<Json>>
? Level extends 'error'
? z.input<
z.ZodType<{
error: Error;
}>
>
: z.input<z.ZodType<Json>>
: Message extends keyof Schema[Level]
? Schema[Level][Message] extends z.ZodType<any, any, any>
? z.input<Schema[Level][Message]>
? z.input<Level extends 'error' ? Schema[Level][Message] & z.ZodType<{ error: Error }> : Schema[Level][Message]>
: undefined
: never;

type DebugMeta<Schema extends BaseSchema, Message extends keyof Schema['debug']> = MetaForSchema<Schema, 'debug', Message>;
type InfoMeta<Schema extends BaseSchema, Message extends keyof Schema['info']> = MetaForSchema<Schema, 'info', Message>;
type WarnMeta<Schema extends BaseSchema, Message extends keyof Schema['warn']> = MetaForSchema<Schema, 'warn', Message>;
type ErrorMeta<Schema extends BaseSchema, Message extends keyof Schema['error']> = {
error: Error;
} & MetaForSchema<Schema, 'error', Message>;
type ErrorMeta<Schema extends BaseSchema, Message extends keyof Schema['error']> = MetaForSchema<Schema, 'error', Message>;

export class Logger<Schema extends BaseSchema> {
private logger: WinstonLogger;
Expand Down

0 comments on commit 0015d59

Please sign in to comment.