Skip to content

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

Closed

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

  1. removed their assignment
    on Jan 16, 2018
  2. mjbvz commented on Jan 16, 2018

    @mjbvz
    ContributorAuthor

    Interesting idea. Perhaps we can leverage the new insertText property on completion items for this

  3. mhegazy commented on Jan 16, 2018

    @mhegazy
    Contributor

    seems like a nice addition to the insertText support we have already.

  4. ghost closed this as completedin #21231on Jan 17, 2018
  5. ghost added
    FixedA PR has been merged for this issue
    on Jan 17, 2018
  6. mhegazy commented on Jan 17, 2018

    @mhegazy
    Contributor

    Anders Lassen (@Duckers) thanks for the suggestion. should be in tomorrow's typescript@next if you want to take if for a spin.

  7. Duckers commented on Jan 17, 2018

    @Duckers

    Fantastic! Thanks a lot :D

  8. locked and limited conversation to collaborators on Jul 3, 2018
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