Generic type variables

The `CommonError` object generic type variables

CommonError<Id>

Idextendsstring

​A generic type variable constrained by the string, by default of the value captured from the provided id indicates the identification type of a new CommonError instance.

common-error.class.ts
abstract class CommonError<
  Id extends string // <--- Declare generic type variable Id.
> extends Error {
  ...
  constructor(
    problem: string,
    fix: string,
    id?: Id, // <--- Capture generic type variable Id.
    template = CommonError.template,
    additional?: { link?: string; max?: number; min?: number; type?: string }
  ) { ... }
  ...
}

Last updated