Generic type variables

The `CommonErrors` generic type variables

CommonErrors<Id>

Idextendsstring

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

common-errors.class.ts
abstract class CommonErrors<
  Id extends string // <--- Declare generic type variable Id.
> {
  constructor(
    ...id: Id[] // <--- Capture generic type variable Id.
  ) {
    Array.isArray(id) && (this.#id = new Set(id));
  }
}

Last updated