File

src/messages.ts

Index

Properties

Properties

code
code: string
Type : string
message
message: string
Type : string
type
type: WarningTypes
Type : WarningTypes
warned
warned: boolean
Type : boolean
Optional
export enum WarningTypes {
  WARNING = 'Warning',
  DEPRECATION = 'DeprecationWarning',
}

export function warn(warning: Warning) {
  // Only show a given warning once
  if (warning.warned) {
    return;
  }
  warning.warned = true;
  if (typeof process !== 'undefined' && process.emitWarning) {
    // @types/node doesn't recognize the emitWarning syntax which
    // accepts a config object, so `as any` it is
    // https://nodejs.org/docs/latest-v8.x/api/process.html#process_process_emitwarning_warning_options
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    process.emitWarning(warning.message, warning as any);
  } else {
    console.warn(warning.message);
  }
}

export interface Warning {
  code: string;
  type: WarningTypes;
  message: string;
  warned?: boolean;
}

result-matching ""

    No results matching ""