score:1
Accepted answer
Consider the following, simpler example:
interface Moment {
prop1: string;
}
const z: Moment[] | number[] = [];
z.includes(1)
// TS2345: Argument of type '1' is not assignable to parameter of type 'Moment & number'.
// Type '1' is not assignable to type 'Moment'.
// Signature of includes in this case:
Array<T>.includes(
searchElement: Moment & number,
fromIndex: number | undefined): boolean
Note that if z can be either Moment or number, than, for includes to succeed in either case, searchElement must be an union of Moment & number
Now, let's take a look at your example:
expandedFilters.experience
// type is string | Moment[] | number[]
Typescript again tries to make union of element types. As string is not an array, it is impossible.
Therefore, it infers type of searchElement to never.
Source: stackoverflow.com
Related Query
- Why does TS give the following error in my case: Argument of type 'number' is not assignable to parameter of type 'never'?
- Why does jest-dom give the error "TypeError: expect(...).not.toBeVisible is not a function" when I use it
- Why am I getting the error message "Property 'then' does not exist on type 'AsyncThunkAction'"?
- Typescript error Type 'string | undefined' does not satisfy the constraint 'string | number | symbol'
- What does the error "JSX element type '...' does not have any construct or call signatures" mean?
- error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist
- Why react-router does not work in the server? It shows 404 error after refreshing the page
- Property 'then' does not exist on type 'RelayObservable<unknown>'. when I try to fetch data using relay in react. I don't know why this error come
- Why do ReactDOMServer and ReactDOM give the "root.hydrate is not a function" error
- Why the following react functional component does not work properly?
- Why do I get an error TS2339: Property 'classList' does not exist on type 'never'?
- Why does Javascript .filter() not return anything with an active filter (== or ===) but works fine if the boolean logic is of type != or !==?
- Why does passing the plot type ('scatter', 'bar', etc.) as string variable does not work? (using <Plot ... /> from react-plotly.js)
- How to fix the error argument of type string or undefined is not assignable to parameter of type string using typescript and react?
- I have the following problem when I delete a row in mySQL database, the serial number does not update to consecutive order
- Why does the load() function with [] as the second argument not run on mount unless I pass in [load] to the second argument?
- I can't figure out why I am getting the following error "Error: Element type is invalid:"
- Why does calling react setState method not mutate the state immediately?
- Error with Redux DevTools Extension using TS: "Property '__REDUX_DEVTOOLS_EXTENSION_COMPOSE__' does not exist on type 'Window'."?
- error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'
- TypeScript error after upgrading version 4 useParams () from react-router-dom Property 'sumParams' does not exist on type '{}'
- getting error : Argument of type '() => () => boolean' is not assignable to parameter of type 'EffectCallback'
- Trying to deploy my React app with gh-pages but got this error message : The "file" argument must be of type string. Received type undefined
- Generics error with forwardRef: Property 'ref' does not exist on type 'IntrinsicAttributes'
- Why does react hook throw the act error when used with fetch api?
- error " Property 'innerText' does not exist on type 'EventTarget' "?
- Why does my Animated view not stay in the correct place in React Native?
- Why getDerivedStateFromProps does not allow to re-render with the state update? Not a problem for componentWillReceiveProps - ReactJS
- Why is this returning the error .contains() is not a function
- Typescript error "Property does not exist on type 'JSX.IntrinsicElements'" when using native web component
More Query from same tag
- Avoid re-render with `useCallback`
- React context path in WAR
- React testing for the TextField element from Material UI
- How to change MIME type with script in ReactJS
- Setting variable to React component not working
- React portal to popup creates instanceof mismatch
- ReactJS: this.props.data.map is not a function
- Getting TypeError: Cannot read property 'map' of undefined error
- How to prevent route change using react-router
- Is it safe to run animations in a useEffect hook?
- How to set api json data to react-select default value
- Overriding TextField color in MaterialUI
- How to extend div to the entire page?
- How to store all array values into a single React state?
- Data not refreshing after adding entry to database React Router
- ReactJS: How to make button background colour change when the text inside it is a certain value
- how to use map and boolean variables inside paths? (can't return the attributes using routers)
- ReactJS - onClick SweetAlert is not working
- Nodejs and ReactJs work together on same server
- How can I get an image from Youtube search App in react?
- Why am I unable to access a Redux store in a child React component?
- Testing connected components with enzyme
- Cannot register Service Worker in React script
- TS2531 | React useRef - Object is possibly undefined
- reduxForm - initialValues did not apply after update
- React useState method in function doesn't work as expected
- How to pass dynamic values to ReactJS JSS?
- How to remove local storage value only on initial loads of the component
- How to automatically fetch data from json server when data gets updated in it in react js
- returning promise from useEffect