Skip to content

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

Description

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

typectxA={funB: (paramA: string)=>void}interfaceTestObj{propA: {funA: (this: ctxA)=>void}}letobjA: 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 anythis.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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

typescriptTypescript support issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions