Skip to content

TypeScript intellisense: Suggest to prepend "this." if I typed the name of a class member #21202

Description

@mjbvz

From Anders Lassen (@Duckers) on January 16, 2018 11:47

Apologies if this is the wrong repo for Intellisense suggestions, if so, please redirect me.

  • VSCode Version: 1.19.1
  • OS Version: MacOS 10.13

A very common scenario when writing TypeScript (coming from C#) is that I forget to prepend this. when I want to reference a member of the current class. My muscle memory also relies a lot on the intellisense to complete the names of members. This very often results in the code completer completing an identifier with a very unlikely option from the global namespace, instead of simply prepending this. to refer to a local member.

Example:

import { Post } from 'Server/Boost/Post'

export default class PostComponent {
    Options = {} as Post.Post

    get hasImage() {
        return Opt<caret here, pressing enter>
    }
}

This ends up completing as HTMLOptionElement or something similar, when this.Options would have been a much more probable intention.

Copied from original issue: microsoft/vscode#41668

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueSuggestionAn idea for TypeScriptVS 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