-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set explicit void return type in function builder if set by the user #24
Comments
Agreed. |
I created #25 |
I agree it would be great to add this to prevent It's also important to note that ![]() In case anyone finding this is interested in a workaround until the issue is addressed, I defined a type alias // Workaround for https://github.com/outfoxx/typescriptpoet/issues/24
val voidType = TypeAliasSpec
.builder("Void", TypeName.VOID)
.addTSDoc("Workaround for https://github.com/outfoxx/typescriptpoet/issues/24")
.build()
fileSpecBuilder.addType(voidType)
val someInterface = InterfaceSpec
.builder("MyInterface")
.addFunction(
FunctionSpec
.builder("doSomething")
.addModifiers(Modifier.ABSTRACT)
.returns(TypeName.implicit("Void"))
.build()
)
.build()
fileSpecBuilder.addType(someInterface) Which outputs: /**
* Workaround for https://github.com/outfoxx/typescriptpoet/issues/24 */
type Void = void;
interface MyInterface {
doSomething(): Void;
} |
@Legion2 @tinacious I've been quite preoccupied with other projects. I'll spend some time updating this project. |
That includes merging #25 😉 |
When the return type is explicitly set to void it should also be set in the generated code explicitly to void. When enabling strict type checking in typescript compiler with the
noImplicitAny
option, all functions without explicit return type default to any.Following code must be changed:
typescriptpoet/src/main/java/io/outfoxx/typescriptpoet/FunctionSpec.kt
Lines 107 to 109 in 62d7d4b
The text was updated successfully, but these errors were encountered: