DEV Community

Sneachta O'Fuichtard
Sneachta O'Fuichtard

Posted on

Property 'value' does not exist on type 'never'.

Hi

I have some code which works ...

selectedOptions.forEach(function (value) {
      console.log(value);
      console.log(value.value);
      console.log(value.label);
    }); 
Enter fullscreen mode Exit fullscreen mode

console.log(value) gives
{value: 'Choice 1', label: 'Choice 1', isInTree: true}

However if I try to pass "selectedOptions" to a function (code below) it gives an error on
console.log(value.value);

Saying Property 'value' does not exist on type 'never'.

Also
console.log('itemIsInSelectedOptions is now:' + value);
gives me ...
itemIsInSelectedOptions is now:[object Object]

Any ideas?
Thanks
S

public render(): React.ReactElement<IReactFilteredListProps> {
    const { selectedOptions } = this.state;




this.setState({
        selectedOptions,
        Items: Text ? this._allItems.filter(i => this.itemIsInSelectedOptions(i.Category, selectedOptions)) : this._allItems
      });

private itemIsInSelectedOptions(theCategory: string, selOpts:[]): boolean
  {

    selOpts.forEach(function (value) {
      console.log('itemIsInSelectedOptions is now:' + value);
      console.log(value.value);
      //console.log(value.label);
    }); 

    return true;
  }


Enter fullscreen mode Exit fullscreen mode

Top comments (0)