Expression expected in TSX

1.2k views Asked by At
 function conatinstemplatename(): boolean{
       let filtered = props.sessionLanguages.filter(x => x.templateName !== ' ').toArray();
       (filtered.length > 0)? return true : return false;
    }

The above line of code is returning expression expected error near the conditional statement.

1

There are 1 answers

1
Dan Starns On

You cant return inside the ternary operator. Return the whole expression.

function conatinstemplatename(): boolean{
 let filtered = props.sessionLanguages.filter(x => x.templateName !== ' ').toArray();

 return (filtered.length > 0) ? true : false;
}