Skip to content
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

Add support for the intersection type A & B #46

Merged
merged 4 commits into from Oct 17, 2017
Merged

Conversation

@exoego
Copy link
Contributor

@exoego exoego commented Oct 15, 2017

Convert the intersection type A & B & C into A with B with C.

It can be used to express using mixins, as seen in jQuery, React or Archiver

@exoego exoego force-pushed the exoego:intersection-type branch from 91a3e1b to da38c76 Oct 15, 2017
@@ -47,7 +47,7 @@ class TSDefParser extends StdTokenParsers with ImplicitConversions {
"{", "}", "(", ")", "[", "]", "<", ">",
".", ";", ",", "?", ":", "=", "|",
// TypeScript-specific
"...", "=>"
"...", "=>", "&"

This comment has been minimized.

@sjrd

sjrd Oct 17, 2017
Owner

& should be next to | above, ideally.

This comment has been minimized.

@exoego

exoego Oct 17, 2017
Author Contributor

Done in 0922a54

@@ -314,6 +314,18 @@ object TypeRef {
}
}

object Intersection {
def apply(types: List[TypeRef]): TypeRef =
TypeRef(QualifiedName.Root, types)

This comment has been minimized.

@sjrd

sjrd Oct 17, 2017
Owner

QualifiedName.Root does not make any sense, here. There should be a dedicated Name.INTERSECTION with a pseudo-name, such as "<with>", similar to Name.SINGLETON.

This comment has been minimized.

@exoego

exoego Oct 17, 2017
Author Contributor

Done in d5c796a

@@ -197,6 +197,10 @@ class Printer(private val output: PrintWriter, outputPackage: String) {
implicit val withPipe = ListElemSeparator.Pipe
p"$types"

case TypeRef.Intersection(types) =>
implicit val withPipe = ListElemSeparator.WithKeyword

This comment has been minimized.

@sjrd

sjrd Oct 17, 2017
Owner

This val should called withWith. It's awkward, but definitely less than withPipe which is a plain lie ;)

This comment has been minimized.

@exoego

exoego Oct 17, 2017
Author Contributor

Done in 37921e7

@exoego
Copy link
Contributor Author

@exoego exoego commented Oct 17, 2017

Thanks for reviewing. All requested changes are done!

@sjrd
Copy link
Owner

@sjrd sjrd commented Oct 17, 2017

OK, looks good. You'll have to rebase on top of the latest master, though, since there is a conflict.

@exoego exoego force-pushed the exoego:intersection-type branch from d5c796a to 875fb7c Oct 17, 2017
@exoego
Copy link
Contributor Author

@exoego exoego commented Oct 17, 2017

@sjrd Conflicts resolved

@sjrd
sjrd approved these changes Oct 17, 2017
@sjrd sjrd changed the title Add support of the intersection type A & B Add support for the intersection type A & B Oct 17, 2017
@sjrd sjrd merged commit 6c47bd3 into sjrd:master Oct 17, 2017
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@exoego exoego deleted the exoego:intersection-type branch Nov 14, 2017
exoego referenced this pull request in exoego/scala-js-ts-importer Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants