foundry-vtt-types
foundry-vtt-types copied to clipboard
Fix logic for indeterminate nullable/required
trafficstars
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.
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.