More concise way to specify an optional return type #41902
Labels
Declined
The issue was declined as something which matches the TypeScript vision
Suggestion
An idea for TypeScript
Suggestion
TypeScript already supports optional parameters and fields with a question mark.
Why not extend this feature to function/getter return types.
Use Cases/Examples
this would allow defining of optional getters as well:
Alternative syntax would be to specify question mark after the name, or even after the braces:
However, I find myself trying the first version of the syntax every time, which currently results in compile error.
This would compliment the usage of question mark
?
as nullablity/unefineability operator, similar to Kotlin.Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: