microsoft / microsoft/TypeScript

More object literal snippet completions for `string`, `Object`, `Array` and `boolean` properties

Open
#52,739 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: LS: Completion Lists In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Suggestion

🔍 Search Terms

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

✅ Viability Checklist

My suggestion meets these guidelines:

  • [z] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [z] This wouldn't change the runtime behavior of existing JavaScript code
  • [z] This could be implemented without emitting different JS based on the types of the expressions
  • [z] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • [z] This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

I think many users find includeCompletionsWithObjectLiteralMethodSnippets super useful, I have an idea to do the same for other types.

📃 Motivating Example

declare const configureMe: (options: {
    name: string
    type: 'a' | 'b'
    enable: boolean
    otherOptions: Record<string, any>
    mixins: any[]
}) => void

configureMe({
    
})
Screenshot 2023-02-13 at 13 04 31

Snippet completions described by types:

string : "$1",$0
boolean : ${1|true,false|},$0
arrayLike : [$1],$0 or : [\n\t$1\n],$0
object (but not class or regexp) : {$1},$0 or : {\n\t$1\n},$0`

Also I think preference should be added to allow these object literal completions with snippet to be displayed above original suggestions (or even remove these original suggestion, if user really wants it) eg completionsWithObjectLiteralSnippetsNonSnippetPosition: /*default*/ 'before' | 'after' | 'remove'

Also in vscode plugin I found extremely useful triggering additional suggest widget after such snippet completion accept.

Can I try to implement this if its good?

Note: I use on a daily basis with my TS plugin: here is current implementation if someone is interested.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked current implementation at typescript/src/completions/objectLiteralCompletions.ts and compare its behavior with the requested TypeScript completions. Done means supporting the listed string, boolean, array-like, and object snippet forms, while resolving the proposed preference behavior and validating the resulting completion suggestions.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.