Closed silkentrance closed 5 years ago
I hear you on this request.
Unfortunately, separate distinctions of undefined
vs. null
is mostly unique to JS. So if JSON5 supported undefined
, it wouldn't translate well to many other languages.
Thus, I lean towards keeping undefined
out of JSON5. Hopefully your workaround is workable!
With TypeScript, it is possible to denote a given property for being optional, e.g.
Now, when creating an instance of Node
And running this through for example Mocha/Chai using a data driven test approach, with the following test data
Will result in differences since chai.assert.deepEqual will now see a
and comparing that to the test data will yield said differences since the test data cannot contain any undefined properties.
A possible work around for this is to define the interface as such
In which case you can have augmented test data such as
which will then pass the chai.assert.deepEqual() assertion.
So, for the sake of completeness I propose that we can also have the 'undefined' in addition to '+Infinity', '-Inifinity', 'NaN' and 'null'.
What do you think?