-
Notifications
You must be signed in to change notification settings - Fork 61
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
Support for Kotlin Nullability in TypeScript Type Generation #3162
Comments
I have the same problem, but the other way around, which means I always get optional types e.g. P.S: The use of optional types |
Using |
Let's assume that the language overrides any other annotations, including JSR305 |
Ideally, |
This comment has been minimized.
This comment has been minimized.
|
Describe your motivation
When generating TypeScript types from Kotlin backend models, nullability information is not always preserved. For example, a nullable Kotlin field (String?) is often mapped to a string type in TypeScript instead of string | null. This causes issues where TypeScript developers assume the field is non-nullable, leading to potential runtime errors.
Given the following Kotlin data class:
The generated TypeScript type looks like this:
Describe the solution you'd like
Update the TypeScript type generation logic in Hilla to correctly map Kotlin nullable types (T?) to TypeScript T | null.
Describe alternatives you've considered
Maybe JSR305 could be used to annotate the affected source code explicitly
Additional context
Kotlin Version: 2.1.0
Hilla Version: Vaadin 24.6.2
The text was updated successfully, but these errors were encountered: