Skip to content

Commit 6339492

Browse files
committed
Add explicit void return type if set by user
1 parent 62d7d4b commit 6339492

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/io/outfoxx/typescriptpoet/FunctionSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private constructor(
104104
codeWriter.emitCode("]")
105105
}
106106

107-
if (returnType != null && returnType != TypeName.VOID) {
107+
if (returnType != null) {
108108
codeWriter.emitCode(CodeBlock.of(": %T", returnType))
109109
}
110110
}

src/test/java/io/outfoxx/typescriptpoet/test/FunctionSpecTests.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ class FunctionSpecTests {
197197
}
198198

199199
@Test
200-
@DisplayName("Generates no return type when void")
201-
fun testGenNoReturnTypeForVoid() {
200+
@DisplayName("Generates return type when void")
201+
fun testGenReturnTypeForVoid() {
202202
val testClass = FunctionSpec.builder("test")
203203
.returns(TypeName.VOID)
204204
.build()
@@ -210,7 +210,7 @@ class FunctionSpecTests {
210210
out.toString(),
211211
equalTo(
212212
"""
213-
function test() {
213+
function test(): void {
214214
}
215215
216216
""".trimIndent()

0 commit comments

Comments
 (0)