Generic type variables

The `ValidationError` object generic type variables

ValidationError<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 ValidationError instance.

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

Last updated