Skip to content

Commit

Permalink
Merge pull request #109 from exoego/trailing-comma-in-args
Browse files Browse the repository at this point in the history
Allow trailing comma in function type
  • Loading branch information
sjrd committed Sep 9, 2019
2 parents 1a9a723 + 0797949 commit 8fe92ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions samples/comma.d.ts
Expand Up @@ -12,3 +12,12 @@ export interface Bar {
key1: string,
key2: string,
}

export type Callback<R> = (
value: R
) => void;

export type Handler<T,R> = (
event: T,
callback: Callback<R>,
) => void;
7 changes: 7 additions & 0 deletions samples/comma.d.ts.scala
Expand Up @@ -17,4 +17,11 @@ trait Bar extends js.Object {
var key2: String = js.native
}

@js.native
@JSGlobalScope
object Comma extends js.Object {
type Callback[R] = js.Function1[R, Unit]
type Handler[T, R] = js.Function2[T, Callback[R], Unit]
}

}
Expand Up @@ -251,7 +251,7 @@ class TSDefParser extends StdTokenParsers with ImplicitConversions {
"<" ~> rep1sep(typeDesc, ",") <~ ">"

lazy val functionType: Parser[TypeTree] =
tparams ~ ("(" ~> repsep(functionParam, ",") <~ ")") ~ ("=>" ~> resultType) ^^ {
tparams ~ ("(" ~> repsep(functionParam, ",") <~ opt(",") <~ ")") ~ ("=>" ~> resultType) ^^ {
case tparams ~ params ~ resultType =>
FunctionType(FunSignature(tparams, params, Some(resultType)))
}
Expand Down

0 comments on commit 8fe92ec

Please sign in to comment.