From 57a96850d4b6c29f7487a5d76754cd26eb894e07 Mon Sep 17 00:00:00 2001 From: Hanna Becker Date: Tue, 5 Nov 2019 23:48:23 +0100 Subject: [PATCH] [spotify-web-playback-sdk] Extend Image interface with width and height properties (#40120) * [spotify-web-playback-sdk] Extend Image interface with width and height properties * [spotify-web-playback-sdk] Extend Image interface with width and height properties, implement review suggestion --- types/spotify-web-playback-sdk/index.d.ts | 3 +++ .../spotify-web-playback-sdk-tests.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/types/spotify-web-playback-sdk/index.d.ts b/types/spotify-web-playback-sdk/index.d.ts index b79a46f632..e3ec73e57b 100644 --- a/types/spotify-web-playback-sdk/index.d.ts +++ b/types/spotify-web-playback-sdk/index.d.ts @@ -4,6 +4,7 @@ // Marcus Weiner // Moritz Gunz // Daniel Almaguer +// Hanna Becker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -33,7 +34,9 @@ declare namespace Spotify { type ErrorTypes = 'account_error' | 'authentication_error' | 'initialization_error' | 'playback_error'; interface Image { + height?: number | null; url: string; + width?: number | null; } interface PlaybackContext { diff --git a/types/spotify-web-playback-sdk/spotify-web-playback-sdk-tests.ts b/types/spotify-web-playback-sdk/spotify-web-playback-sdk-tests.ts index 692a062971..0d80e24fd8 100644 --- a/types/spotify-web-playback-sdk/spotify-web-playback-sdk-tests.ts +++ b/types/spotify-web-playback-sdk/spotify-web-playback-sdk-tests.ts @@ -32,6 +32,10 @@ player.getCurrentState().then((playbackState: Spotify.PlaybackState | null) => { if (playbackState) { const { current_track, next_tracks } = playbackState.track_window; const repeatMode: 0 | 1 | 2 = playbackState.repeat_mode; + const images = current_track.album.images; + if (images.length) { + const { 0: { height, width } } = images; + } console.log("Currently Playing", current_track); console.log("Playing Next", next_tracks[0]);