diff --git a/src/state.ts b/src/state.ts index f9c75be..89e8df1 100644 --- a/src/state.ts +++ b/src/state.ts @@ -103,10 +103,7 @@ class Observer { return this.create({ ...data, type: 'loading', message }); }; - promise = ( - promise: PromiseT, - data?: PromiseData, - ) => { + promise = (promise: PromiseT, data?: PromiseData) => { if (!data) { // Nothing to show return; @@ -127,9 +124,12 @@ class Observer { let shouldDismiss = id !== undefined; p.then((response) => { - if (response.ok !== undefined && !response.ok) { + // TODO: Clean up TS here, response has incorrect type + // @ts-expect-error + if (response && typeof response.ok === 'boolean' && !response.ok) { shouldDismiss = false; const message = + // @ts-expect-error typeof data.error === 'function' ? data.error(`HTTP error! status: ${response.status}`) : data.error; this.create({ id, type: 'error', message }); } else if (data.success !== undefined) { diff --git a/website/src/components/Types/Types.tsx b/website/src/components/Types/Types.tsx index a3fef38..8f1b0e3 100644 --- a/website/src/components/Types/Types.tsx +++ b/website/src/components/Types/Types.tsx @@ -114,6 +114,6 @@ toast.promise(promise, { { name: 'Custom', snippet: `toast(
A custom toast with default styling
)`, - action: () => toast(
A custom toast with default styling
), + action: () => toast(
A custom toast with default styling
, { duration: 1000000 }), }, ];