Skip to content

this any typed in some JS object literals  #22058

Open
@mjbvz

Description

@mjbvz

From microsoft/vscode#43930

TypeScript Version: 2.8.0.insiders-20180211

Search Terms:

  • this
  • object literal

Code
For the js:

console.log({
    a: 1,
    b() {
        this
  }
});

Hover over this in b

Bug
this has any type

this is properly typed in cases like:

const z = {
    a: 1,
    b() {
        this
  }
}

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallyHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosVS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions