3992 Fix: handle null duration in toast ns function

extend SnackbarEvents typing to allow null in third argument
also remove typos in Electron.tsx init functions comments
This commit is contained in:
Roman Ivaniuk
2022-08-19 14:38:46 +03:00
parent 9c579e294a
commit 5c0c130b4b
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -1849,7 +1849,7 @@ const base: InternalAPI<NS> = {
(_message: unknown, _variant: unknown = ToastVariant.SUCCESS, _duration: unknown = 2000): void => {
const message = helpers.string(ctx, "message", _message);
const variant = helpers.string(ctx, "variant", _variant);
const duration = helpers.number(ctx, "duration", _duration);
const duration = _duration === null ? null : helpers.number(ctx, "duration", _duration);
if (!checkEnum(ToastVariant, variant))
throw new Error(`variant must be one of ${Object.values(ToastVariant).join(", ")}`);
SnackbarEvents.emit(message, variant, duration);