Skip to content

variable name _this breaks in checkJs #22866

Description

@mohsen1

TypeScript Version: 2.7.2

Search Terms:
_this
Code
Real world example

https://github.com/webpack/webpack/blob/7f11210cffc58820b4cdd086934398306882c338/lib/Compilation.js#L454

Expected behavior:
No Error
Actual behavior:

TS2400: Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.

Playground Link:

Related Issues:
webpack/webpack#6862

Activity

  1. mhegazy commented on Mar 26, 2018

    @mhegazy
    Contributor

    Here is a simplified repro:

    // @ts-check
    
    class Base { }
    
    class C extends Base {
        constructor() {
            super();
        }
    
        foo() {
            let _this = this;
            
            () => {
                _this
            };
        }
        
    }
  2. added a commit that references this issue on Mar 26, 2018
    7fd602e
  3. mhegazy commented on Mar 26, 2018

    @mhegazy
    Contributor

    Mohsen Azimi (@mohsen1) fix should be in tonight's typescript@next.

  4. added a commit that references this issue on Mar 26, 2018
    faa3fca
  5. locked and limited conversation to collaborators on Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions