import { JsonObject } from "../../lib/Core/Json"; import { AllowsUndefined, Equals, IsWritable, IsWritableArray } from "../../lib/Core/TypeConditionals"; import ModelPropertiesFromTraits from "../../lib/Models/Definition/ModelPropertiesFromTraits"; import TraitsForTesting from "./TraitsForTesting"; import { expectFalse, expectTrue } from "./TypeChecks"; type ModelProperties = ModelPropertiesFromTraits; const modelProperties: ModelProperties = {} as any; // Simple properties allow undefined only if they do not have a default. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue< Equals >(); expectTrue< Equals >(); expectTrue< Equals >(); // No properties can be modified. expectFalse>(); expectFalse>(); // Properties that are nested traits do not allow undefined even if they do not have a default. expectFalse>(); expectFalse>(); const _nested = modelProperties.nestedWithDefault; // Nested properties allow undefined only if they do not have a default. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue>(); expectTrue>(); // Nested properties may not be modified. expectFalse>(); expectFalse>(); // Properties that are arrays of traits allow undefined only if they do not have a default. expectFalse>(); expectFalse< AllowsUndefined >(); // Array traits are not writable. expectFalse< IsWritableArray> >(); expectFalse< IsWritableArray> >(); const array = modelProperties.nestedArrayWithDefault; if (array) { const _first = array[0]; // Arrays may not _contain_ undefineds. expectFalse>(); // Properties in traits in arrays allow undefined only if they do not have a default. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue>(); expectTrue>(); // Properties in traits in arrays can not be modified. expectFalse>(); expectFalse>(); }