Skip to content

Enable interface-over-type-literal lint rule#17733

Merged
1 commit merged into
masterfrom
interface-over-type-literal
Sep 7, 2017
Merged

Enable interface-over-type-literal lint rule#17733
1 commit merged into
masterfrom
interface-over-type-literal

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Aug 10, 2017

This would lint that we always use an interface instead of type T = { ... };.
Thoughts? We already mostly follow this pattern.

Copy link
Copy Markdown
Contributor

@uniqueiniquity uniqueiniquity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@weswigham
Copy link
Copy Markdown
Member

I personally don't see the point of enforcing it on non-exported declarations. Plus - if you use an interface as an implementation detail, and the object becomes part of the return value, suddenly the interface must be exported, too - which is not true of aliases.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Sep 6, 2017

I am on the fence for this one too. we have used interfaces throughout. but do not see why type aliases are bad. with latest changes to caching/instantiation, the two should be more of less similar from performance perspective.

@ghost ghost merged commit 193f4be into master Sep 7, 2017
@ghost ghost deleted the interface-over-type-literal branch September 7, 2017 16:15
@ghost
Copy link
Copy Markdown
Author

ghost commented Sep 7, 2017

suddenly the interface must be exported, too

I think this is actually a good thing -- there's no good reason to hide a type if the values of that type are returned from a public function. It might trick you into thinking it's OK to make changes to a private type, but changing anything about the type would change the type of an exported value.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
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.

4 participants