Skip to content

Commit

Permalink
Resolve type errors: Quick Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieS1103 committed Dec 15, 2023
1 parent d7e3528 commit e40c2eb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/components/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Grid extends React.Component<
version: string,
newUpdate: boolean,
searchValue: string,
cards: Card[],
cards: typeof Card[],
tabs: TabItemConfig[],
rest: boolean,
endOfList: boolean,
Expand Down Expand Up @@ -78,6 +78,7 @@ class Grid extends React.Component<
lastScroll = 0;
requestQueue: never[][] = [];
requestPage = 0;
// @ts-expect-error: `'Card' refers to a value, but is being used as a type here.`
cardList: Card[] = [];
sortConfig: { by: string };
// TODO: why are these set up funny
Expand Down Expand Up @@ -129,7 +130,7 @@ class Grid extends React.Component<
updateActiveTheme={this.setActiveTheme.bind(this)}
/>;

this.cardList.push(card as unknown as Card);
this.cardList.push(card as unknown as typeof Card);
}

// TODO: this isn't currently used, but it will be used for sorting (based on the SortBox component)
Expand Down Expand Up @@ -162,7 +163,7 @@ class Grid extends React.Component<
this.cardList = this.cardList.map((card, index) => {
return <Card {...card.props}
key={index.toString()} CONFIG={this.CONFIG} />;
}) as unknown as Card[];
}) as unknown as typeof Card[];
this.setState({ cards: [...this.cardList] });
}

Expand Down
1 change: 1 addition & 0 deletions src/components/Modals/BackupModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const BackupModal = () => {
* Prompt user to select a file to import and then run importMarketplace
*/
const importSettingsFromFile = async () => {
// @ts-expect-error: `showOpenFilePicker not defined in type Window`
const fileHandle = await window.showOpenFilePicker();
const file = await fileHandle[0].getFile();
const text = await file.text();
Expand Down
5 changes: 1 addition & 4 deletions src/extensions/extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import {
injectColourScheme(activeScheme);

// Add to Spicetify.Config
// @ts-expect-error: `color_scheme` is read-only type in types

Spicetify.Config.color_scheme = themeManifest.activeScheme;
if (localStorage.getItem(LOCALSTORAGE_KEYS.albumArtBasedColor) === "true") {
initAlbumArtBasedColor(activeScheme);
Expand All @@ -119,7 +119,6 @@ import {
injectUserCSS(userCSS);

// Add to Spicetify.Config
// @ts-expect-error: `current_theme` is read-only type in types
Spicetify.Config.current_theme = themeManifest.manifest?.name;

// Inject any included js
Expand Down Expand Up @@ -169,9 +168,7 @@ import {
window.sessionStorage.setItem("marketplace-request-tld", tld);

// Save to Spicetify.Config for use when removing a theme
// @ts-expect-error: Config doesn't have a `local_theme` property
Spicetify.Config.local_theme = Spicetify.Config.current_theme;
// @ts-expect-error: Config doesn't have a `local_color_scheme` property
Spicetify.Config.local_color_scheme = Spicetify.Config.color_scheme;
const installedThemeKey = localStorage.getItem(LOCALSTORAGE_KEYS.themeInstalled);
if (installedThemeKey) initializeTheme(installedThemeKey);
Expand Down
2 changes: 1 addition & 1 deletion src/logic/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export const initAlbumArtBasedColor = (scheme: ColourScheme) => {

// If it doesn't exist, wait for it to load
if (albumArtSrc == null) {
albumArtSrc = await waitForAlbumArt();
albumArtSrc = await waitForAlbumArt() as string;
}

if (albumArtSrc) {
Expand Down
6 changes: 4 additions & 2 deletions src/types/spicetify.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1997,10 +1997,12 @@ declare namespace Spicetify {
*/
namespace Config {
const version: string;
const current_theme: string;
const color_scheme: string;
let current_theme: string;
let color_scheme: string;
const extensions: string[];
const custom_apps: string[];
let local_theme : string;
let local_color_scheme : string;
}

/**
Expand Down

0 comments on commit e40c2eb

Please sign in to comment.