★ Constructor
The `TypeError` object constructor
TypeError()
TypeError()Creates a TypeError instance that represents type error with the message built of the given described problem and its solution, optional type, and an explicit identification on the supplied or stored error message template.
constructor(
problem: string,
fix: string,
id?: Id,
type?: Type,
template = TypeError.template
) {
super(problem, fix, id, template, { type });
this.#type = type;
}Parameters
Description of the problem of a string type.
A solution to the given problem of a string type.
Optional unique identification to the given problem of generic type variable Id.
type?:Type
type?:TypeThe optional type of generic type variable Type that causes an error to be thrown(or not thrown).
Optional template of the error message of string type with the replaceable {problem}, {fix} and optional {id}, {type} tags. By default, the value is equal to the static property TypeError.template.
Example usage
// Example usage.
import { TypeError } from '@angular-package/error';
// Returns
// TypeError: Problem(TE:201): Wrong type => Fix: The type of `age` parameter must be of the string
new TypeError('Wrong type', 'Change the type', '(TE:201)', 'string');Last updated
Was this helpful?