Should we drop null
?
#443
mxdvl
started this conversation in
Team Posts
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Whilst there is a small semantic difference between
undefined
andnull
, we tend to use either somewhat interchangeably in our codebases. When using Typescript, there are a lot of shorthands forundefined
values that don’t exist fornull
, such as the question mark?
against a key, or declaring alet
without using a union type. Also,typeof null === "object"
. See Sindre Sorhus’s idea for other reasons.Following a chat discussion, the value of a change needs to be proven. So I’ll try to find concrete examples where we would gain from choosing to drop
null
from our codebase, maybe using an ESLint plugin.One key thing to keep in mind is that we you cannot use
undefined
in JSON.WIP List, while I get to a minimum of 5
getCookie
returnsnull
, even if the cookie isn’t present.coreWebVitals
we coerce from undefined to null, which leads to strange types. This may be because JSON does not supportundefined
values, but our backend processing will lead to the same data being in BigQuery.Beta Was this translation helpful? Give feedback.
All reactions