Hello i converted Java script code into type Type Script the every this is working fine but Following issue is i am facing while Development pls explain the exact issue and help me out in this thanks in advance
import { useTheme } from "../../stores/theme"; const bestNewSounds = useSearch(); const { data: categories } = useCategories(); const { theme } = useTheme(); //Property 'theme' does not exist on type 'ThemeContextType | undefined'. const [under10MinSongs, setUnder10MinSongs] = useState([]); const fetchSongsUnder10Min = async () => { const { data } = await axios.get("/songs/duration/600"); setUnder10MinSongs(data.data.results); //Object is of type 'unknown'. };
theme.tsx
import React, { createContext, useContext, useState } from "react"; import { ThemeProvider as StyledThemeProvider } from "styled-components"; import themes from "../themes/"; type ThemeContextType = { theme: string; setTheme: (value: string) => void; };const ThemeContext = createContext<ThemeContextType | undefined>(undefined);export const ThemeProvider = ({ children}:{children:any}) => {const [theme, setTheme] = useState<any>(themes["dark"]);const [themeKey, setThemeKey] = useState("dark");const setLightTheme = () => {setTheme(themes["light"]);setThemeKey("light");};const setDarkTheme = () => {setTheme(themes["dark"]);setThemeKey("dark");};const toggleTheme = (switchTheme = null) => {if (switchTheme !== null) { setTheme(themes[switchTheme]);} else { if (themeKey === "dark") { setLightTheme(); } else { setDarkTheme(); }}};return (<ThemeContext.Provider value={{ theme, toggleTheme, themeKey }}><StyledThemeProvider theme={theme}>{children}</StyledThemeProvider></ThemeContext.Provider>);};export const useTheme = () => {return useContext(ThemeContext);};