When I try to use spotify's web playback sdk, I'm stuck with specifying the type.
import React, { useEffect } from 'react';
import { getAccessToken } from '../store/reducers/rootReducer';
function WebPlayBack() {
useEffect(() => {
const script = document.createElement("script");
script.src = "https://sdk.scdn.co/spotify-player.js";
script.async = true;
document.body.appendChild(script);
window.onSpotifyWebPlaybackSDKReady = () => {
const player = new window.Spotify.Player({
name: 'Mucketlist',
getOauthToken: (cb: any) => {
cb(getAccessToken('')),
},
volume: 0.5,
});
player.addListener("ready", ({ device_id }) => {
console.log("Ready with Device ID", device_id);
});
player.addListener("not_ready", ({ device_id }) => {
console.log("Device ID has gone offline", device_id);
});
player.connect();
}
}, []);
return <div></div>;
}
export default WebPlayBack;
The opaque type in the above function is onSpotifyWebPlaybackSDKReady, Spotify, device_id. I searched the reference in the Spotify official documentation, but there is no information about the type. How to solve it?