Skip to content

Commit 86b8201

Browse files
committed
Add workaround for JS targets
1 parent 41644d5 commit 86b8201

File tree

1 file changed

+9
-1
lines changed
  • src/commonMain/kotlin/com/kgbier/graphql/parser

1 file changed

+9
-1
lines changed

src/commonMain/kotlin/com/kgbier/graphql/parser/Parsers.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
/**
2+
* Redundant Unit returns are necessary when running in JS.
3+
* Functions which do not explicitly return a Unit value will return `undefined` in JS.
4+
*/
5+
@file:Suppress("RedundantUnitExpression")
6+
17
package com.kgbier.graphql.parser
28

39
import com.kgbier.graphql.parser.structure.Maybe
410

511
internal object Parsers {
612

7-
val always: Parser<Unit> = Parser { }
13+
val always: Parser<Unit> = Parser { Unit }
814

915
fun <Output> always(constant: Output): Parser<Output> = Parser { constant }
1016

@@ -62,6 +68,7 @@ internal object Parsers {
6268
val match = p(it)
6369
if (match != null) return@Parser null
6470
}
71+
Unit
6572
}
6673

6774
val int: Parser<Int> = Parser {
@@ -90,6 +97,7 @@ internal object Parsers {
9097
fun literal(literal: String): Parser<Unit> = Parser {
9198
if (it.startsWith(literal)) {
9299
it.advance(literal.length)
100+
Unit
93101
} else null
94102
}
95103

0 commit comments

Comments
 (0)