p42ai / js-assistant

120+ refactorings and code-assists for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=p42ai.refactor
MIT License
119 stars 7 forks source link

Showing wrong hint for inline-return #5

Closed chandan192 closed 2 years ago

chandan192 commented 2 years ago

Original code:

    public replaceVariables(path: Path, variables: { [key: string]: string }) {
        const me = this;
        let newPath;

        newPath = me.resolvePath(path);

        Object.keys(variables).forEach((variable: string) => {
            newPath.replace('{' + variable + '}', variables[variable]);
        });

        return newPath;
    }

Screenshot 2021-11-10 133109

code after the fix:

    public replaceVariables(path: Path, variables: { [key: string]: string }) {
        const me = this;
        let newPath;

        return me.resolvePath(path);

        //unreachable code after fix
        Object.keys(variables).forEach((variable: string) => {
            newPath.replace('{' + variable + '}', variables[variable]);
        });

    }

c

lgrammel commented 2 years ago

Thanks for the detailed bug report! I'll update once I have a fix.

lgrammel commented 2 years ago

@chandan192 I just released version 1.50.5, which fixes the bug. Please re-open this issue if you still encounter the bug 1.50.5 or higher. Thanks again for the bug report!