Skip to content

Commit

Permalink
Add explicit void return type if set by user
Browse files Browse the repository at this point in the history
  • Loading branch information
Legion2 committed Jul 26, 2023
1 parent 62d7d4b commit 6339492
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/outfoxx/typescriptpoet/FunctionSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private constructor(
codeWriter.emitCode("]")
}

if (returnType != null && returnType != TypeName.VOID) {
if (returnType != null) {
codeWriter.emitCode(CodeBlock.of(": %T", returnType))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ class FunctionSpecTests {
}

@Test
@DisplayName("Generates no return type when void")
fun testGenNoReturnTypeForVoid() {
@DisplayName("Generates return type when void")
fun testGenReturnTypeForVoid() {
val testClass = FunctionSpec.builder("test")
.returns(TypeName.VOID)
.build()
Expand All @@ -210,7 +210,7 @@ class FunctionSpecTests {
out.toString(),
equalTo(
"""
function test() {
function test(): void {
}

""".trimIndent()
Expand Down

0 comments on commit 6339492

Please sign in to comment.