Generic type variables

The `TypeError` object generic type variables

TypeError<Id,Type>

Idextendsstring=string

​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 TypeError instance.

type-error.class.ts
class TypeError<
  Id extends string,  // <--- Declare generic type variable Id.
  Type extends string | undefined = undefined
> extends Error {
  ...
  constructor(
    problem: string,
    fix: string,
    id?: Id, // <--- Capture generic type variable Id.
    type?: Type,
    template = TypeError.template
  ) { ... }
  ...
}

TypeError<Id,Type>

A generic type variable constrained by the string and undefined, by default of the value equal to undefined indicates the captured type of the supplied type of a new TypeError instance.

type-error.class.ts
class TypeError<
  Id extends string,
  Type extends string | undefined = undefined  // <--- Declare generic type variable Type.
> extends Error {
  ...
  constructor(
    problem: string,
    fix: string,
    id?: Id,
    type?: Type,  // <--- Capture generic type variable Type.
    template = TypeError.template
  ) { ... }
  ...
}

Last updated