Skip to content

Copilot-based infer types from usage for Typescript #190690

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

Closed
wants to merge 4 commits into from

Conversation

sandersn
Copy link
Member

This is a prototype of a copilot-based codefix that's the equivalent of Typescript's Infer From Usage codefix. Unlike that codefix, it uses only the body of the function (and any surrounding code) to infer types. However, it creates new interfaces with reasonable names and uses them where appropriate, which the old codefix cannot.

I have a lot of open questions about how this codefix should work, so I want to get it into Insiders, perhaps with an attached survey. I found that the copilot chat extension already logs telemetry about which button users press on the editorChat window, which might be good enough.

Some open questions:

  • Will enough people see this experiment if it's behind the typescript.experimental.aiQuickFix setting?
  • Is it better to show this as a separate codefix or a followup? As a refactor? Right now it's a separate codefix, because (1) the existing codefix can interfere with the LLM-based inference (2) the results are quite different, so it makes sense to present as different to the user.
  • Could the codefix could be skipped if there are lots of types around already?
  • Could the codefix prompt by modified to omit "Please generate new interfaces" if there lots of interfaces already declared?
  • This branch is based on code by people on the vscode team, but I don't see any commits but mine. Are the other experiments merged to main already?

More work needed:

  • The codefix is offered in JS files but always produces Typescript types, not JSDoc ones. I haven't found a prompt that works, at least.

@sandersn
Copy link
Member Author

@jrieken and @mjbvz I'd like you to look at this, but maybe you know others who should review it as well.

@sandersn
Copy link
Member Author

sandersn commented Sep 8, 2023

Superceded by #192602

@sandersn sandersn closed this Sep 8, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants