score:0
the problem here is that rawlistitemcachevalue[list]
is not the same as listdatamap[list][]
, even though it really looks like it is.
if you check the error you will see whats the difference is in that line:
commentdata | devicedata | userdata is not assignable to type commentdata
.
what this means is that when yo do this:
type rawlistitemcachevalue = {
// [name of list]: array of list items
[list in listname]?: listdatamap[list][];
};
somehow you are telling tsc
this:
type rawlistitemcachevalue = {
[commentdata]?: listdatamap[commentdata][];
[devicedata]?: listdatamap[devicedata][];
{...}
};
so the key and the value are correlated.
the problem is that when you do listdatamap[list][]
with list
being === to keyof listname
, this value can be anyone on listdatamap
. so when you do listitemcache[list] = items;
you are really doing:
listitemcache['commentdata' | 'devicedata' | 'userdata'] = (commentdata | devicedata | userdata)[]
so tsc
complains for that because listitemcache['commentdata'] = devicedata
would be a possible combination which is wrong.
Source: stackoverflow.com
Related Query
- Proxied Object Assignment Type Error TypeScript
- Object is of type unknown error when using Typescript with React
- Typescript type error while destructuring on empty object with default values?
- Typescript giving error on defining type defination for object
- What TypeScript type should I use to reference the match object in my props?
- TypeScript error after upgrading version 4 useParams () from react-router-dom Property 'sumParams' does not exist on type '{}'
- Typescript React <Select> onChange handler type error
- Type Error when using Typescript with React-Redux
- ReactJS typescript error Parameter props implicitly has 'any' type
- React-router + typescript type error
- Typescript error "Property does not exist on type 'JSX.IntrinsicElements'" when using native web component
- CombineReducers with Typescript returns error "Argument of type is not assignable to parameter of type 'ReducersMapObject'"
- React Typescript error in TextArea : Type 'string' is not assignable to type number
- React SSR error -- Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object
- FlatList scrollToIndex using useRef with Typescript - Type Error
- Creating reusable Button Component with React and Typescript with not assignable type error
- Transpiling error in Typescript with React: Property does not exist on type 'IntrinsicAttributes'
- Styled-jsx typescript error after migrating to monorepo structure. Property 'jsx' does not exist on type 'DetailedHTMLProps'
- React Custom Hook with Typescript Type error "Property 'x' does not exist on type 'interface | (({ target }: any) => void)'.ts(2339)"
- React Router DOM History Object Causes Typescript Error
- React / Typescript : pushing obj into array of object and undefined type
- Typescript returns error when a function type is FunctionalComponent, but not for arrow function
- TypeScript error in undefined(undefined,undefined): Cannot find type definition file for 'src'. TS2688
- Typescript how to type custom key in an object
- react-google-recaptcha "ref" type error in React typescript
- react-material table with typescript shows generic type error
- React + Typescript object props to component error
- binding element 'yyy' implicitly has an 'any' type error in typescript
- TypeScript type for value of key in object
- Typescript - infer generic type from object prop value
More Query from same tag
- How to resolve React-Jsx/html input error -$NaN.undefined
- Allow chinese characters and English numbers only in textbox - Javascript
- FBXLoader can't find version number of fbx file
- Enzime: Wait that context is updated to start execute tests
- Updating only one property inside an array of objects react
- What needs to be done to call third party Reactjs component from Anguarjs 1 using ngReact?
- How to display the information submitted in the html form on another page using react js?
- Update progress bar in for loop
- Convert words to mobile numeric keypad sequence
- React functional component in nested maps rerender multiple times
- Redux state doesn't log the properties of the state object
- Typescript provides error on react key property - Property 'key' does not exist on type
- Displaying JSON data on front-end using fetch
- JavaScript anonymous function parameters and calling arrangement
- How to access react-app build from local file url ("file:///"), without using any HTTP server?
- Memoizing PusherJS subscriptions in a react app
- How to fetch a value of key from localStorage and put it to input by hooks?
- Is there any proper way to send a POST request through React using fetch()?
- Make use of event handler in React Component for TSX tag
- Is there any other way to show the month,year except dropdown in react-datepicker?
- Delete item from data in reactjs and redux
- Issues with response from express file to front end (React)
- React: How to read state from within handler function?
- "TypeError: props.todos.map is not a function" can't figure out what the cause is?
- `moduleNameMapper` settings in jest.config.js doesn't work on CircleCI
- How do I make an accessible onClick handler for links in React?
- How to get single element from firebase
- How to access and loop over nested JSON items in React?
- How to get the difference from dyanamically added fields- react
- How to change the style of one element when I hover another element (ReactJS)?