Currently facing a challenging Typescript problem that has me puzzled.
The issue arises at the line
themeToChange[tileId][key] = value;
The error message states
Type 'any' is not assignable to type 'never'
This error is directly related to the introduction of the TileLayout
type. I'm having difficulty pinpointing the mistake. Interestingly, adding the value "None"
to the TileLayout
type resolves the error.
const changeSetting = React.useCallback(
(key: keyof TileSettings, value: ValueOfTileSettings, tileId: TileId) => {
const userSettings = JSON.parse(JSON.stringify(settings)) as UserSettings;
const themeToChange = getCurrentTheme(userSettings, colorMode);
themeToChange[tileId][key] = value;
setSettings(userSettings);
},
[colorMode, setSettings, settings]
);
Provided below are the type definitions:
export type TileLayout = "STANDARD" | "COMPACT";
export type TileType =
| "Reddit Feed"
| ...
| "RSS Feed Tile"
| "None";
export type TileSettings = { ... };
export type ThemeSettings = { ... };
Any assistance on this matter would be greatly appreciated! :)