You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Experiment with threading AI into extraction refactorings #182779
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.
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
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.
Reacted by Demian Ferreiro, Matt, Albert Mañosa, Nicolás Pérez, Théo LUDWIG, Vitaly, Ray, Omri Luzon and Daniel Rosenwasser
Activity
spartanatreyu commentedon May 18, 2023
This should be controlled by a setting for sure.
Here are the outcomes I can see with this feature:
newLocalornewFunctionis a part of their proofing workflow (with eyeballs, linters, git hooks, or other code analysis tools).zardoy commentedon Jun 1, 2023
I think TypeScript should try to infer name using common naming conventions at least (such as

use...orget...), 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.
10 remaining items
amunger commentedon Jun 25, 2024
Daniel Rosenwasser (@DanielRosenwasser) - is this the newly added behavior?
mjbvz commentedon Jun 26, 2024
Marking this as an exploration. We'll create test items for the individual features that came out of it