Skip to content

Support class member snippet completions in JS filesΒ #46738

Open
@gabritto

Description

@gabritto

Suggestion

Support class member snippet completions in JS files

πŸ” Search Terms

class member completion

βœ… Viability Checklist

My suggestion meets these guidelines:

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

⭐ Suggestion

We should have class member snippet completions work in JS files. Currently they only work in TS files.

πŸ“ƒ Motivating Example

class Base {
    /**
     * @param {number} a
     * @param {number} b
     */
    foo(a, b) {
        return a + b;
    }
}

class Sub extends Base {
    | // Suggest `foo(a, b) { }` here, like we do in TS files
}

Considerations

To properly support JS, we would have to consider the many ways in which properties can be added to a class in JS. We also should make sure the completion suggestion has JSDoc when possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Completion ListsThe issue relates to showing completion lists in an editorSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions