JohnWeisz / TypedJSON

Typed JSON parsing and serializing for TypeScript that preserves type information.
MIT License
604 stars 64 forks source link

[Discussion] `parse`, `toPlainJson`, `toPlainArray`, `toPlainMap`, `toPlainSet` should not return `undefined` #166

Open MatthiasKunnen opened 3 years ago

MatthiasKunnen commented 3 years ago

Returning undefined instead of throwing an error is an old approach and quite annoying because it requires a !== undefined check or non-null assertion on every call.

I would like these methods to throw instead of returning undefined.

This will not change that, for example, array elements that fail to deserialize get substituted with undefined.

MatthiasKunnen commented 3 years ago

WIP: https://github.com/JohnWeisz/TypedJSON/compare/master...MatthiasKunnen:parser-no-undefined