Skip to content

Commit

Permalink
feat(types): use union type for ConsolaLogObject.type (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
trygveaa authored Aug 5, 2020
1 parent 625d7df commit a6eba53
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions types/consola.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,24 @@ export enum LogLevel {
Verbose= Infinity,
}

export type logType =
| 'silent'
| 'fatal'
| 'error'
| 'warn'
| 'log'
| 'info'
| 'success'
| 'debug'
| 'trace'
| 'verbose'
| 'ready'
| 'start'

export interface ConsolaLogObject {
level?: LogLevel,
tag?: string,
type?: string,
type?: logType,
message?: string,
additional?: string | string[],
args?: any[],
Expand All @@ -25,15 +39,15 @@ export interface ConsolaLogObject {

export interface ConsolaReporterLogObject {
level: LogLevel,
type: string,
type: logType,
tag: string;
args: any[],
date: Date,
}

type ConsolaMock = (...args: any) => void

type ConsolaMockFn = (type: string, defaults: ConsolaLogObject) => ConsolaMock
type ConsolaMockFn = (type: logType, defaults: ConsolaLogObject) => ConsolaMock

export interface ConsolaReporterArgs {
async: boolean,
Expand All @@ -47,7 +61,7 @@ export interface ConsolaReporter {

export interface ConsolaOptions {
reporters?: ConsolaReporter[],
types?: { [type: string]: ConsolaLogObject },
types?: { [type in logType]: ConsolaLogObject },
level?: LogLevel,
defaults?: ConsolaLogObject,
async?: boolean,
Expand Down

0 comments on commit a6eba53

Please sign in to comment.