score:1
Accepted answer
You have to implicitly tell TypeScript that this is the array of the keys of the state.
const SomeFields: Array<keyof State>
This is also improving TS experience as you will get code completion in your editor/IDE when trying to e.g. add an element to SomeFields
or use switch
etc.
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 {}
- Element implicitly has an 'any' type because expression of type 'string' can't be used to index type React Typescript
- Typescript with React > Element implicitly has an 'any' type because expression of type 'string' can't be used to index
- issue typing an object react typescript - Element implicitly has an 'any' type because type'
- Typescript react - Could not find a declaration file for module ''react-materialize'. 'path/to/module-name.js' implicitly has an any type
- React Typescript: Element implicitly has an 'any' type because type has no index signature
- Graphql React Typescript error binding element 'currency' implicitly has an 'any' type
- React typescript error: Element implicitly has an 'any' type
- TypeScript - Element implicitly has an 'any' type because expression of type '"storyFile"' 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
- 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
- Parameter 'e' implicitly has an 'any' type React TypeScript
- TypeScript (ReactJS) compiler error, this implicitly has type any
- binding element 'yyy' implicitly has an 'any' type error in typescript
- TypeScript / ReactJS / setTimeout: 'this' implicitly has type 'any' because it does not have a type annotation.ts
- 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
- 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
- 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 '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
- React component in TypeScript if passed as parameter and assigned to variable; TS2604: JSX element type does not have any construct or call signatures
- element implicitly has an 'any' type because type 'yyy' has no index signature.ts(7017)
- Typescript when I map imports it says 'Element implicitly has an 'any' type because expression of type 'string' to index type 'typeof import'
- Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'Item'
More Query from same tag
- use state is not working in useffect and showing this error
- How to secure client app (react) and API communication
- How to add http:// if it doesn't exist in a string containing multiple URLs
- How does a chained export work in react without the components in between actually rendering the component?
- React Router - Auto navigate to first nested route when visiting parent route
- Rendering HTMLDivElements in ReactJS
- Ensuring user permits Microphone access before firing event in React app
- How to ensure state is not stale in React hook
- Map function loops and gives error - React
- How to deploy a react js app on a No-CPanel VPS which will be using nodejs/mongodb in the backend?
- Why am I getting match is not a function when it is clearly defined?
- Passing CSRF token to REACT/FLUX from node
- Brand new to react and confused on how I omit an item from a function and also inject a button into my grid
- Why do an object key without [] will not be the accepted parameter?
- Inline SVG in react 16
- TypeError: Cannot read property 'map' of undefined in react redux
- Common modifications for all actions in reducer
- Formik - "dirty" gets applied to all instances with the same custom component
- How to set responsive style to react modal in React js?
- Next.js access query on initial render { amp: undefined }
- useParams for category of products
- Uncaught SyntaxError: Unexpected token '<' From ReactJS when behind Gateway (Reverse Proxy)
- Problems while developing a reactjs app
- How to make a div scale to the max height available?
- ReactJS server-side rendering vs client-side rendering
- How to add a Website in a ReactJs responsive web app?
- Is it possible to render array of components?
- I am getting error in console "You need to enable JavaScript to run this app." reactjs
- Auth0 async await return session user
- Warning: A component is changing a controlled input of type text to be uncontrolled. (React.js)