Skip to content
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

TypeScript this Type Information Dosen't Surface Properly in Editor #12032

Closed
thoughtentity opened this issue Sep 14, 2016 · 2 comments
Closed
Assignees
Labels
typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@thoughtentity
Copy link

TypeScript this Type Information Dosen't Surface Properly in Editor

Environment Information

  • VS Code Version: 1.6.0-insiders (f31a4)
  • OS Version: Windows 10 1607 (Build 14393.105)
  • TypeScript Version: 2.0.2 (Release Candidate)

Problem

In TypeScript 2.0, the shape of this for functions can be described using type annotations. However, the VS Code TypeScript editor does not properly surface this information. The this variable in the function gets typed as any within the function but the editor still enforces that use of this in the function conform to the type information used to describe this for the function. This results in the odd issue of the editor not providing any intellisense for the this due to it being typed as any but still expects it conform to the shape of this described by the this type annotation for the function.

image

Reproduction

The following minimum TypeScript file will reproduce the issue in VS Code.

index.ts

type ctxA = {
    funB: (paramA: string) => void
}

interface TestObj {

    propA: {
        funA: (this: ctxA) => void
    }

}

let objA: TestObj = {

    propA: {
        funA: function() {
            // errors since funB dosen't match the signature (missing paramA) of funB in ctxA even though the editor types it as any
            this.funB();
        }
    }

}

Expected Result

The VS Code TypeScript editor should properly surface the type information for this in functions and not just type it as any to provide proper intellisense.

@waderyan
Copy link

@thoughtentity thank you for the excellent bug report. One of the best explained and demonstrated I have ever seen 👍. I have reproduced. As this issue is a TypeScript language service issue I will migrate to their repo.

@waderyan
Copy link

This issue was moved to microsoft/TypeScript#10937

@waderyan waderyan added upstream Issue identified as 'upstream' component related (exists outside of VS Code) typescript Typescript support issues labels Sep 15, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

2 participants