0

I am getting error:

Parsing error: Expression expected

Here is my code base:

    export interface TableRow {
      rowKey: string;
      rowCells: {[key: string]: any};
      rowExpanded?: React.ReactNode;
    }
class MvSortTable extends React.Component<Props, State> {
 ...
      toggleAllRows = () => {
        const shouldExpand = this.allRowsCollapsed(this.state.expandedRows);
        const expandedRows: {[key: string]: boolean} = {};
    
        this.props.rows?.forEach((row) => {
         expandedRows[row.rowKey] = shouldExpand;
        });
    
        this.setState({ expandedRows, allRowsCollapsed: !shouldExpand });
      }
...

Error come from when I add ? into this.props.rows...

How can I fix this error?????

Nhan Nguyen
  • 355
  • 1
  • 6
  • 24

2 Answers2

0

It could be a problem related to:

OR

cheesyMan
  • 1,494
  • 1
  • 4
  • 13
0

If anyone else is facing this issue you might want to check the eslint-plugin-prettier in your package.json.

I recently stumbled upon this issue and I found that the project I was working on was on the older version.

Just upgrade eslint-plugin-prettier, at the time of writing this the latest version is 4.0.0

Cheers!!

Rupesh Chaudhari
  • 308
  • 2
  • 3
  • 12
  • In case someone runs into this: I was actually using prettier in a nextjs by itself and this caused the issue for some reason. Switched to eslint-plugin-prettier as recommended https://nextjs.org/docs/basic-features/eslint Fixed my issue related unexpected "Expression expected" errors – Arthur Goldsmith Apr 28 '23 at 21:55