Skip to content

add support for extract as interface#31644

Merged
andrewbranch merged 4 commits intomicrosoft:masterfrom
Kingwl:extract_interface
Aug 28, 2019
Merged

add support for extract as interface#31644
andrewbranch merged 4 commits intomicrosoft:masterfrom
Kingwl:extract_interface

Conversation

@Kingwl
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Kingwl commented Jun 26, 2019

🆙

@Kingwl
Copy link
Copy Markdown
Contributor Author

Kingwl commented Aug 6, 2019

🙋🏻‍♂️

@andrewbranch
Copy link
Copy Markdown
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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
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.

Refactoring: Extract to interface

3 participants