Skip to content

Experiment with threading AI into extraction refactorings #182779

Closed

Description

Today, TSServer provides several actions for "extract to function" and "extract to local" for both TypeScript and JavaScript. Currently, TSServer just creates a pre-generated name like newLocal or newFunction that's sufficiently unique. While this is fine, it would be interesting if we could use a language model to come up with a useful name and calculate a better name while TypeScript itself calculates the refactoring.

In cases where a language model can "confidently" calculate a new name, that name can replace the contents of the automatically-invoked rename for the refactor.

Activity

  1. spartanatreyu commented on May 18, 2023

    @spartanatreyu

    This should be controlled by a setting for sure.

    Here are the outcomes I can see with this feature:

    • A user refactors some code, likes the AI generated name and decides to use it.
    • A user refactors some code and sees the AI generated name, but they want to make a slight tweak to the name.
    • A user reactors some code and doesn't want to use the AI generated names at all.
      • Perhaps the user is consistently getting bad suggestions for the particular thing they are trying to do.
      • Perhaps seeing pre-generated names like newLocal or newFunction is a part of their proofing workflow (with eyeballs, linters, git hooks, or other code analysis tools).
      • The user is against using AI for some other reason
  2. zardoy commented on Jun 1, 2023

    @zardoy
    Contributor

    I think TypeScript should try to infer name using common naming conventions at least (such as use... or get...), just like vscode-postfix-ts extension does:

    From my experience it covers ~20% of code and can be useful if AI suggestions are slow, unavailable or a user doesn't want to use the AI generated names at all.

  3. 10 remaining items

  4. amunger commented on Jun 25, 2024

    @amunger
    Collaborator

    Daniel Rosenwasser (@DanielRosenwasser) - is this the newly added behavior?

    image

  5. mjbvz commented on Jun 26, 2024

    @mjbvz
    Contributor

    Marking this as an exploration. We'll create test items for the individual features that came out of it

  6. locked and limited conversation to collaborators on Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions