score:4
Accepted answer
parentColor
is any
, not a keyof Palette
. To remove the error, you need to assert it with the correct type:
// "primary" | "secondary" | "error" | "warning" | "info" | "success"
type PaletteKey = keyof {
[Key in keyof Palette as Palette[Key] extends PaletteColor ? Key : never]: true;
}
// "light" | "dark" | "main" | "contrastText"
type PaletteColorKey = keyof PaletteColor
theme.palette[parentColor as PaletteColorKey][childColor as PaletteColorKey]
Source: stackoverflow.com
Related Query
- react typescript error - element implicitly has an any type because expression of type string cant be used to index type {}
- TS | Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Record<SecurityMode, boolean>'
- Element implicitly has an 'any' type because expression of type 'any' can't be used to index type
- Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Palette'
- Element implicitly has an 'any' type because expression of type 'string' can't be used to index type React Typescript
- Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'typeof
- Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{...}'
- Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Breakpoints'
- how fix Element implicitly has an 'any' type because expression of type 'string' can't be used to index type?
- Global window object: Element implicitly has an 'any' type because index expression is not of type 'number'.ts
- TypeScript - Element implicitly has an 'any' type because expression of type '"storyFile"' can't be used to index type '{}'
- Typescript with React > Element implicitly has an 'any' type because expression of type 'string' can't be used to index
- Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'Item'
- Nested Object -> Element implicitly has an 'any' type because expression of type 'string' can't be used to index type
- Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}' - React Anagram
- Element implicitly has an 'any' type because expression of type 'string | number' can't be used to index type
- error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index 'ModuleType'
- Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'Number'
- Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'
- Element implicitly has an 'any' type because expression of type 'number' can't be used to index type '{}'
- Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ 1: Element; 2: Element; 3: Element; }'. TS7053
- Element implicitly has an 'any' type because expression of type 'any' can't be used to index type with createStyles
- Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'BGColors'
- Typescript error in map(): Element implicitly has an 'any' type because expression of type 'string' can't be used to index type
- error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist
- TypeScript Err: "Element implicitly has an 'any' type because expression of type 'any' can't be used to index type
- Typescript-React State: Element implicitly has an 'any' type because type 'State' has no index signature
- How do I fix the error "Element implicitly has an 'any' type because the expression of type
- React Typescript: Element implicitly has an 'any' type because type has no index signature
- element implicitly has an 'any' type because type 'yyy' has no index signature.ts(7017)
More Query from same tag
- Fetching and Sorting inside React Function
- Unable to render React function using ReactDOM
- React material ui form validation on textfield not working
- Edit Functionality React
- Value of Select Tag from state dom is not changing in react
- ReactJs - How to get updated state while inside a thunk promise
- Displaying components depending on one variable with multiple variables as conditions
- How can I show a modal using an animation with Tailwind and react.js?
- Reactjs component does not call componentWillMount method when route is matched
- How to generate a transparent canvas using html2canvas
- Figure out if a component is going to be updated or not in react
- clearInterval not stopping my counter in useEffect
- React findOne returning undefined on Client
- Access to an Array inside a Post Array with Sanity using next.js
- Error Importing with scss @import in storybook
- Material UI - Facing an issue that drop down options are coming below the modal window footer
- Call Java methods in Javascript using React
- ReactJS - custom component launching all tooltips
- Why do I need 'bind(this)' in the example above
- How to set event handler in React sub-component
- React: updating array props won't trigger useEffect hook
- React: save ref to state in a custom hook
- Have text above icon in React JS
- "Unsafe assignment of an any value" when using react-transition-group with TypeScript
- Update input box when outside is clicked in ReactJS
- How do conditionally render a node based on a field at a specific index when mapping out elements in React?
- How to calculate mouse position relative to drawing area when it hovers over element being drawn
- Updating state as a nested object
- Can access event.target, which has a value attribute, but event.target.value always returns undefined?
- Undefined value. Trying to set ID with fetch