Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Breaking: Change how interface node gets converted (fixes #201) #241

Merged
merged 1 commit into from
May 1, 2017

Conversation

soda0289
Copy link
Member

This commit create an TSInterfaceDeclration and TSInterfaceBody node when converting typescript interface

@soda0289 soda0289 requested a review from JamesHenry April 29, 2017 21:56
@eslintbot
Copy link

LGTM

@azz
Copy link
Contributor

azz commented Apr 30, 2017

Do we need superTypeParameters for interfaces too?

interface B<C, D> { }
interface A extends B<string, number> { }

Never mind, it's covered by TSInterfaceImplements's typeParameters.

@soda0289
Copy link
Member Author

I should change my tests to use extends. I thought interfaces implement other interfaces, but that's a mistake.

Maybe change the nose type to TSInterafceExtends?

@@ -0,0 +1,3 @@
interface Foo implements Bar {
Copy link
Member

Choose a reason for hiding this comment

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

It's not a parse error, but this is invalid TypeScript

Interface declaration cannot have 'implements' clause.

@@ -0,0 +1,3 @@
interface Foo<T> implements Bar<J> {
Copy link
Member

Choose a reason for hiding this comment

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

See comment about this being invalid TypeScript

@JamesHenry
Copy link
Member

When this is updated to use extends, we could go for superInterface to align with superClass? There is no precedent in flow AFAIK...

@JamesHenry
Copy link
Member

JamesHenry commented Apr 30, 2017

On the whole, I definitely like the change, we may even want to look at refactoring the body in a future PR. Flow uses ObjectTypeAnnotation for that and a few other things. Not sure that existed when we started this

@azz
Copy link
Contributor

azz commented Apr 30, 2017

When this is updated to use extends, we could go for superInterface to align with superClass? There is no precedent in flow AFAIK...

Can't. Unlike a class, an interface can extend many other interfaces or classes.

https://astexplorer.net/#/gist/5ef8ee37c06a2390c37aae0f9a61ed04/bf68403565ba586b351e1a46c73d1a4232c6cdca

@JamesHenry
Copy link
Member

How about heritage: TSNode[]?

Then we could even capture the semantically invalid implements examples in the AST, as TypeScript itself would...

@soda0289
Copy link
Member Author

I'd be fine with using heritage. I'll also change the heritage node to TSInterfaceExtends but it could be TSInterfaceHeritage.

@eslintbot
Copy link

LGTM

@soda0289
Copy link
Member Author

@JamesHenry I changed implements property to heritage.Also changed the node type to TSInterfaceHeritage

This commit create an TSInterfaceDeclration and TSInterfaceBody
node when converting typescript interface
@eslintbot
Copy link

LGTM

@JamesHenry
Copy link
Member

I'm pretty happy with this to go in now, thanks @soda0289! 😄

Any other thoughts @azz?

@azz
Copy link
Contributor

azz commented May 1, 2017

LGTM 👍

@JamesHenry JamesHenry merged commit b1efe69 into master May 1, 2017
@JamesHenry JamesHenry deleted the interface-body branch May 1, 2017 12:30
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