From b9c260660dee244d10ec09653106afd2237acdac Mon Sep 17 00:00:00 2001 From: Ollie Taylor <13766232+OllieJT@users.noreply.github.com> Date: Sat, 25 Feb 2023 01:40:17 +0000 Subject: [PATCH] Makes typings easier to override --- src/lib/audio/index.ts | 24 +++++++++++------------- src/lib/types.ts | 8 ++++---- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/lib/audio/index.ts b/src/lib/audio/index.ts index d9f5dd8..bd0cceb 100644 --- a/src/lib/audio/index.ts +++ b/src/lib/audio/index.ts @@ -16,7 +16,7 @@ import type { AudioLoadData, AudioLoadOptions } from '$lib/types'; import { secondsToTimestamp } from '$lib/utility/seconds-to-timestamp'; import { info, warn } from '$pkg/log'; import clamp from 'just-clamp'; -import { derived } from 'svelte/store'; +import { derived, type Readable } from 'svelte/store'; export { default as AudioLoader } from '$lib/audio/audio-loader.svelte'; export const podcast_time = derived([_current_time, _ended], ([$seconds, $ended]) => ({ @@ -25,22 +25,20 @@ export const podcast_time = derived([_current_time, _ended], ([$seconds, $ended] ended: $ended, })); -export const podcast_data = derived( +export const podcast_data: Readable = derived( [_src, _metadata], - ([$src, $metadata]) => - ({ - ...$metadata, - src: $src, - } satisfies AudioLoadData), + ([$src, $metadata]) => ({ + ...$metadata, + src: $src, + }), ); -export const podcast_options = derived( +export const podcast_options: Readable = derived( [_start_at, _autoplay], - ([$start_at, $autoplay]) => - ({ - start_at: $start_at, - autoplay: $autoplay, - } satisfies AudioLoadOptions), + ([$start_at, $autoplay]) => ({ + start_at: $start_at, + autoplay: $autoplay, + }), ); export const podcast_duration = { subscribe: _duration.subscribe }; diff --git a/src/lib/types.ts b/src/lib/types.ts index 00a42c5..6cf569b 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -1,9 +1,9 @@ export type AudioPlayerElement = HTMLAudioElement | undefined; -export type AudioMetadata = Partial<{ - title: string; - artwork: string; -}>; +export interface AudioMetadata { + title?: string; + artwork?: string; +} export interface AudioLoadData extends AudioMetadata { src: string;