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 intellisense: Suggest to prepend "this." if I typed the name of a class member #21202

Closed
mjbvz opened this issue Jan 16, 2018 · 4 comments
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jan 16, 2018

From @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

@mjbvz mjbvz self-assigned this Jan 16, 2018
@mjbvz mjbvz removed their assignment Jan 16, 2018
@mjbvz mjbvz added VS Code Tracked There is a VS Code equivalent to this issue and removed javascript labels Jan 16, 2018
@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 16, 2018

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

@mhegazy mhegazy added the Suggestion An idea for TypeScript label Jan 16, 2018
@mhegazy mhegazy assigned ghost Jan 16, 2018
@mhegazy mhegazy added this to the TypeScript 2.8 milestone Jan 16, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jan 16, 2018

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

@ghost ghost closed this as completed in #21231 Jan 17, 2018
@ghost ghost added the Fixed A PR has been merged for this issue label Jan 17, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jan 17, 2018

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

@Duckers
Copy link

Duckers commented Jan 17, 2018

Fantastic! Thanks a lot :D

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

3 participants