2 Commits

Author SHA1 Message Date
Elijah Duffy
e8440bc106 1.2.0 2026-05-04 03:34:14 -07:00
Elijah Duffy
d1019659f5 ErrorMessage: accept unknown in constructor 2026-04-21 18:08:57 -07:00
2 changed files with 5 additions and 5 deletions

View File

@@ -4,7 +4,7 @@
"type": "git", "type": "git",
"url": "https://gitea.auvem.com/svelte-toolkit/sui.git" "url": "https://gitea.auvem.com/svelte-toolkit/sui.git"
}, },
"version": "1.1.3", "version": "1.2.0",
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",
"build": "vite build && pnpm run prepack", "build": "vite build && pnpm run prepack",

View File

@@ -78,7 +78,7 @@ export class ErrorMessage {
* @param errors The raw errors to convert and store, or null/undefined for no error. * @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. * @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; if (errors.length === 0) return;
this._lines = errors.flatMap((e) => ErrorMessage.rawErrorToLines(e)); 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 * Creates a new ErrorMessage only if the provided errors are not null or
* undefined. If no errors are provided, returns null. * 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; if (errors.length === 0) return null;
return new ErrorMessage(...errors); 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. * @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. * @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; if (errors.length === 0) return this;
const newLines = errors.flatMap((e) => ErrorMessage.rawErrorToLines(e)); const newLines = errors.flatMap((e) => ErrorMessage.rawErrorToLines(e));
return new ErrorMessage(...newLines, ...this._lines); return new ErrorMessage(...newLines, ...this._lines);
@@ -122,7 +122,7 @@ export class ErrorMessage {
} }
/** converts a RawError to an array of lines */ /** 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 []; if (!raw) return [];
let errorLines: string[]; let errorLines: string[];