A generic type variable constrained by the string, by default of the value captured from the provided 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
) { ... }
...
}
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
) { ... }
...
}
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 of a new TypeError instance.