Skip to content

null vs undefined in TypeScript #825

Closed Answered by pavish
seancolsen asked this question in Developer Q&A
Discussion options

You must be logged in to vote

@seancolsen @dmos62

I think we should go with undefined. I agree on the complexity it'll bring if we use both null and undefined. undefined is the most common return value for a number of inbuilt functions and I think it's more convenient to use it.

We would mostly only want to worry about serialization for handling requests and responses, where null would be essential, but I do not see any other case where we might require null.

In short, for type definitions and return types of functions, we would prefer undefined.
null will only be used where it is strictly necessary such as in requests and responses.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@dmos62
Comment options

@seancolsen
Comment options

@pavish
Comment options

@seancolsen
Comment options

@dmos62
Comment options

Answer selected by seancolsen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants