Skip to content

JS Class expression with js-valued return type methods cause duplicated errors #24252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
weswigham opened this issue May 18, 2018 · 3 comments
Closed
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@weswigham
Copy link
Member

weswigham commented May 18, 2018

Found in #24247

TypeScript Version: 2.9.0-dev.201xxxxx

Search Terms:

Code

// @ts-check
var A = {};
A.B = {};
A.B.C = [
    {
        o: "no",
        y: 42
    }
];

A.Foo = class {
    /**
     * @returns {?A}
     */
    foo() {
        return A.B.C.find(x => !!x);
    }
}

Expected behavior:
image

Actual behavior:
image
(2 errors instead of 1 - one without elaboration)
In trying to edit this down further, I've found that removing the nested namespace on B seems to remove the bug, as does changing the return type of foo to not reference A, or changing from a class to an object literal for A.Foo - so it seems a great deal of things must be kept in place to reproduce this error.

@weswigham weswigham added the Bug A bug in TypeScript label May 18, 2018
@sandersn
Copy link
Member

I can't get this to repro anymore, but the dupes are still in the chrome-devtools-frontend baselines. Looks like I might need to re-isolate this one.

@sandersn
Copy link
Member

Here's a smaller repro:

var A = {};
A.B = class {
    /**
     * @return {any[]}
     */
    m() {
        return {};
    }
};

@sandersn
Copy link
Member

Could be that we're double-checking methods here. Anything with elaborations gets double errors:

var A = {};
A.B = class {
    m() {
        /** @type {string[]} */
        var x = [];
        /** @type {number[]} */
        var y;
        y = x;
    }
};

From a quick debugging run-through, it looks like deferredNodes gets the same node pushed onto it twice.

@sandersn sandersn added the Fixed A PR has been merged for this issue label May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants