ErrorMessage: accept unknown in constructor
This commit is contained in:
@@ -78,7 +78,7 @@ export class ErrorMessage {
|
||||
* @param errors The raw errors to convert and store, or null/undefined for no error.
|
||||
* @throws If any of the raw errors are of an unsupported type.
|
||||
*/
|
||||
constructor(...errors: (RawError | null | undefined)[]) {
|
||||
constructor(...errors: (unknown | null | undefined)[]) {
|
||||
if (errors.length === 0) return;
|
||||
this._lines = errors.flatMap((e) => ErrorMessage.rawErrorToLines(e));
|
||||
}
|
||||
@@ -87,7 +87,7 @@ export class ErrorMessage {
|
||||
* Creates a new ErrorMessage only if the provided errors are not null or
|
||||
* undefined. If no errors are provided, returns null.
|
||||
*/
|
||||
static from(...errors: (RawError | null | undefined)[]): ErrorMessage | null {
|
||||
static from(...errors: (unknown | null | undefined)[]): ErrorMessage | null {
|
||||
if (errors.length === 0) return null;
|
||||
return new ErrorMessage(...errors);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ export class ErrorMessage {
|
||||
* @param errors The raw errors to wrap around this error, or null/undefined for no additional error.
|
||||
* @returns A new ErrorMessage instance that includes the original error and any new errors.
|
||||
*/
|
||||
wrap(...errors: (RawError | null | undefined)[]): ErrorMessage {
|
||||
wrap(...errors: (unknown | null | undefined)[]): ErrorMessage {
|
||||
if (errors.length === 0) return this;
|
||||
const newLines = errors.flatMap((e) => ErrorMessage.rawErrorToLines(e));
|
||||
return new ErrorMessage(...newLines, ...this._lines);
|
||||
@@ -122,7 +122,7 @@ export class ErrorMessage {
|
||||
}
|
||||
|
||||
/** converts a RawError to an array of lines */
|
||||
static rawErrorToLines(raw: RawError | null | undefined): string[] {
|
||||
static rawErrorToLines(raw: unknown | null | undefined): string[] {
|
||||
if (!raw) return [];
|
||||
|
||||
let errorLines: string[];
|
||||
|
||||
Reference in New Issue
Block a user