Skip to content

Commit

Permalink
Fixes DanielXMoore#218. Optional type void => shorthand (DanielXMoore…
Browse files Browse the repository at this point in the history
  • Loading branch information
STRd6 committed Jan 13, 2023
1 parent 1b81c39 commit ac77cec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/parser.hera
Original file line number Diff line number Diff line change
Expand Up @@ -4466,7 +4466,12 @@ TypeBinaryOp
return { $loc, token: "&" }

FunctionType
Parameters __ "=>" Type
Parameters __ "=>" Type?:type ->
if (type) {
return $0
}

return [...$0, "void"]

TypeArguments
"<" TypeArgument+ __ ">" ->
Expand Down
11 changes: 11 additions & 0 deletions test/types/function.civet
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ describe "[TS] function", ->
(x) : number => x
"""

testCase """
interface method with void => shorthand
---
interface Array<T>
listen(fu: =>): void
---
interface Array<T> {
listen(fu: ()=>void): void
}
"""

testCase """
no parens is application
---
Expand Down

0 comments on commit ac77cec

Please sign in to comment.