Skip to content

add support for extract as interface #31644

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

Merged
merged 4 commits into from
Aug 28, 2019

Conversation

Kingwl
Copy link
Contributor

@Kingwl Kingwl commented May 29, 2019

Fixes #31640

This pr add another refactor action 'extract to interface', that could extract type literal as an interface, that works within the following case:

  1. TypeLiteralNode: pick members
  2. Parens: skip
  3. Intersection with TypeLiteralNode: merge types

I think we should disallow named object types, and type references. that seems overkill

unsupported:

  1. duplicate member, that will be complicated and weird
  2. named TypeLiteralNode, that seems overkill

@Kingwl
Copy link
Contributor Author

Kingwl commented Jun 26, 2019

🆙

@Kingwl
Copy link
Contributor Author

Kingwl commented Aug 6, 2019

🙋🏻‍♂️

@andrewbranch
Copy link
Member

unsupported:

  1. duplicate member, that will be complicated and weird

I think it’s ok to leave this out, but I’d prefer to bail and not offer the fix when you encounter a duplicate member. It’s less-than-ideal to generate invalid code that’s not another codefix away from being right:

Kapture 2019-08-26 at 14 56 07

@andrewbranch andrewbranch merged commit af9ca21 into microsoft:master Aug 28, 2019
@Kingwl Kingwl deleted the extract_interface branch August 29, 2019 02:19
timsuchanek pushed a commit to timsuchanek/TypeScript that referenced this pull request Sep 11, 2019
* add support for extract as interface

* fix action assert

* Donot provide convert to interface if duplicate member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactoring: Extract to interface
3 participants