You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to know if there's any kind of implementation of Nullable types like in C# or what Flow does called as Maybe Types. I haven't found anything here in the repository exactly like that's still opened nor in the documentation.
What I'm using right now is something like: type Nullable<T> = T | undefined | null. But I think a built-in solution for that (even if it would be like this type I'm using) would be more sophisticated. I saw that TypeScript 2.8 is adding NonNullable<T> globally, so I think the inverse has its use cases as well.
The text was updated successfully, but these errors were encountered:
This was discussed in details in #7426 when --strictnull checks were first introduced. the conclusion was that the explicit T | null | undefined were better type names for most users than Nullable<T> or T?, since it is obvious whether it is T | null or T | undefined or T | null | undefined. We have since decided to be out of the business of naming nullable types for users, and let everyone chose a name that makes most sense to their teams. NonNullable is in contradiction of my previous statement, but the use case here is much more limited than the Nullable, also the type is more involved to write and read, and thus we have opted to add it to the library.
I understand your point, will close the issue then. I just went through the topic you linked, and I'd still disagree.
It's very verbose doing every time: Nullable<Type> or even worse Type | undefined | null. That's the reason Flow provides that feature using the question mark for example. It's the first feature that I see that Flow has and TypeScript doesn't (I prefer so much TS over Flow). That's sad, but... :)
On my side for example, look the difference between those codes:
I'd like to know if there's any kind of implementation of Nullable types like in C# or what Flow does called as Maybe Types. I haven't found anything here in the repository exactly like that's still opened nor in the documentation.
What I'm using right now is something like:
type Nullable<T> = T | undefined | null
. But I think a built-in solution for that (even if it would be like this type I'm using) would be more sophisticated. I saw that TypeScript 2.8 is addingNonNullable<T>
globally, so I think the inverse has its use cases as well.The text was updated successfully, but these errors were encountered: