Update typings
This commit is contained in:
parent
22f5549bc7
commit
3e55182657
@ -9,16 +9,17 @@ type TransportOptions = {
|
||||
} & WriteOptions
|
||||
|
||||
const validKeys = [ 'labels' ];
|
||||
const isTransportOpts = (obj: object): obj is TransportOptions =>
|
||||
const isTransportOpts = (obj: unknown): obj is TransportOptions =>
|
||||
{
|
||||
if (!obj || typeof obj !== 'object')
|
||||
return false;
|
||||
const isWriteOption = isWriteOptions(obj);
|
||||
const keys = Object.keys(obj);
|
||||
return isWriteOption || keys.some(key => validKeys.includes(key));
|
||||
};
|
||||
|
||||
class LoggerClient implements Logger
|
||||
class LoggerClient implements Logger
|
||||
{
|
||||
|
||||
static MaxChars = 0;
|
||||
|
||||
[key: string]: LogFunction | unknown;
|
||||
|
@ -208,7 +208,7 @@ class MasterLogger implements Logger
|
||||
});
|
||||
}
|
||||
|
||||
write (type = 'info', ...args: [...entries: Loggable[], options: WriteOptions])
|
||||
write (type = 'info', ...args: [...entries: Loggable[], options: WriteOptions | Loggable])
|
||||
{
|
||||
const last = args[args.length - 1];
|
||||
let { subheader = '', shard, broadcast = false, labels = [] }: WriteOptions = {};
|
||||
|
@ -10,8 +10,10 @@ export const makePlainError = (err: Error) =>
|
||||
};
|
||||
|
||||
const validKeys = [ 'subheader', 'shard', 'broadcast', 'labels' ];
|
||||
export const isWriteOptions = (obj: object, extended = false): obj is WriteOptions =>
|
||||
export const isWriteOptions = (obj: unknown, extended = false): obj is WriteOptions =>
|
||||
{
|
||||
if (!obj || typeof obj !== 'object')
|
||||
return false;
|
||||
const keys = Object.keys(obj);
|
||||
// Check for invalid keys, in some cases an arbitrary object might share keys
|
||||
// while still allowing for an option to be extended
|
||||
|
@ -23,6 +23,6 @@ type IPCMessage = {
|
||||
|
||||
type LogFunction = (str: string, opts?: WriteOptions) => void
|
||||
|
||||
type Loggable = string | number | object | Error
|
||||
type Loggable = string | number | object | Error | unknown
|
||||
|
||||
export { WriteOptions, Shard, IPCMessage, LogFunction, Loggable };
|
Loading…
Reference in New Issue
Block a user