Skip to content

const function variable cannot reference itself #10912

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
jamiewinder opened this issue Sep 14, 2016 · 1 comment
Closed

const function variable cannot reference itself #10912

jamiewinder opened this issue Sep 14, 2016 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@jamiewinder
Copy link

TypeScript Version: 2.0.2

With this code:

const mouseUpListener = (upEvent: MouseEvent) => {
    // (do something)
    window.removeEventListener('mouseup', mouseUpListener); // *1
};

I get an error on line *1 saying: "Variable 'mouseUpListener' is used before being defined". I can change const to let and it works, but I'm not sure I see the difference (the function body won't ever run until the variable is set, so is const).

Is this expected / correct?

@yortus
Copy link
Contributor

yortus commented Sep 14, 2016

Looks like a duplicate of #9382

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Sep 14, 2016
@mhegazy mhegazy closed this as completed Sep 14, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants