sandstone-mc / sandstone

Sandstone | Next Generation Framework for Minecraft
https://sandstone.dev/
MIT License
173 stars 16 forks source link

Let `RootNBT` and `NBTObject` accept `undefined` values #159

Closed GrantGryczan closed 2 years ago

GrantGryczan commented 2 years ago

NBTObject should accept undefined values, which means NBT.stringify would omit them just as JSON.stringify does.

For the motivation, see this minimal example. This is a niche case, but there isn't really a clean workaround for it without removing type safety.

Additionally, I don't see any practical reason to disallow undefined. I can think of a few other (equally niche) cases where doing so would be problematic as well.

image