League-of-Foundry-Developers / foundry-vtt-types

Unofficial type declarations for the Foundry Virtual Tabletop API
MIT License
112 stars 54 forks source link

Fix logic for indeterminate nullable/required #2597

Open LukeAbby opened 2 months ago

LukeAbby commented 2 months ago

When nullable: boolean users must assume that when getting null is a valid option as nullable may be true. When setting users must assume nullable may be false and therefore be an error. This means that indeterminate values for nullable must be treated differently in different contexts.

The same logic applies for required.

LukeAbby commented 2 months ago

If https://github.com/microsoft/TypeScript/issues/43826 were to be solved this could be perfectly done but I believe at the moment we probably have to be a bit overly conservative to prevent soundness holes.

Fortunately we can tell people to specify required/nullable exactly rather than indeterminately if they care.