Error: Void function return value is used

Viewed 6789

I use Stimulus in Symfony 5 and when I use this code in my Stimulus controller, PhpStorm shows an error.

How can I fix this?

import {Controller} from 'stimulus';
import {index} from "../js/index";
export default class extends Controller{
    connect(){
        const index1 = index();
    }
}

Error: Void function return value is used

My index() function is:

export function index(){
...
}
1 Answers

Use this code:

import {Controller} from 'stimulus';
import Index from "../js/index";
export default class extends Controller{
    connect(){
        const index1 = new Index;
        index1.index();
    }
}

And use this for your index class:

export default class Index {
    index(){
        ...
    }
}
Related